fwrite(size_t_count)

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Sep 2006
Posts: 63
Reputation: rowly is an unknown quantity at this point 
Solved Threads: 3
rowly's Avatar
rowly rowly is offline Offline
Junior Poster in Training

fwrite(size_t_count)

 
0
  #1
Oct 5th, 2006
Hi,
can any one tell me what size_t_count does, i couldnt get it .
thanks guyz !
fwrite(const void*_str,size_t_Size,size_t_count,file *_File);

DarkCoder+
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 275
Reputation: andor has a spectacular aura about andor has a spectacular aura about andor has a spectacular aura about 
Solved Threads: 29
andor's Avatar
andor andor is offline Offline
Posting Whiz in Training

Re: fwrite(size_t_count)

 
1
  #2
Oct 5th, 2006
Originally Posted by rowly View Post
Hi,
can any one tell me what size_t_count does, i couldnt get it .
thanks guyz !
fwrite(const void*_str,size_t_Size,size_t_count,file *_File);
It means how many of size_t_Size you want to write.
fwrite(buff, sizeof(int), 4, someFile) means you want to write four ints to file.
Last edited by andor; Oct 5th, 2006 at 9:40 am.
If you want to win, you must not loose (Alan Ford)
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 63
Reputation: rowly is an unknown quantity at this point 
Solved Threads: 3
rowly's Avatar
rowly rowly is offline Offline
Junior Poster in Training

Re: fwrite(size_t_count)

 
0
  #3
Oct 5th, 2006
aha beautifull ! now i got it !

1 more question !

strcpy(rcust[i].item, strtok(NULL,","));
i used the strtok to read untill i reach a comma...
how can i replace the comma by a ";" ?
for example i want to do the same thing but now i want to write it to another file and replace the , by a semi colon ?!
have any idea how to do that with strtok or another function ?!

thx champ
DarkCoder+
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,648
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1498
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: fwrite(size_t_count)

 
0
  #4
Oct 5th, 2006
use strchr() to find the comma then replace it
  1. char str[] = "Hello,World";
  2. // find the comma
  3. char *ptr = strchr(str,',')
  4. // replace it if found
  5. if(ptr != NULL)
  6. *ptr = ';';

Now, put the above in a loop to find and replace all the commas in the string.
Last edited by Ancient Dragon; Oct 5th, 2006 at 9:55 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 63
Reputation: rowly is an unknown quantity at this point 
Solved Threads: 3
rowly's Avatar
rowly rowly is offline Offline
Junior Poster in Training

Re: fwrite(size_t_count)

 
0
  #5
Oct 5th, 2006
aha !
if i want to write to a file, do i have to fread it first or just
fwrite it straight away ?
thx champ



DarkCoder+
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 90
Reputation: Inanna is on a distinguished road 
Solved Threads: 6
Inanna's Avatar
Inanna Inanna is offline Offline
Junior Poster in Training

Re: fwrite(size_t_count)

 
0
  #6
Oct 5th, 2006
if i want to write to a file, do i have to fread it first or just
fwrite it straight away ?
It's tricky. Can you post some code that shows what you're trying to do?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,648
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1498
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: fwrite(size_t_count)

 
0
  #7
Oct 5th, 2006
Originally Posted by rowly View Post
aha !
if i want to write to a file, do i have to fread it first or just
fwrite it straight away ?
thx champ
of course the program has to read it -- how else do you think it is going to be able to know where the commans are and what to write to the new file?
  1. for each line in the source file
  2. read a line
  3. replace all commas with semicolons
  4. write the string to the new file
  5. end
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,127
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 283
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: fwrite(size_t_count)

 
0
  #8
Oct 5th, 2006
Actually, you read from one file, then write to another file. You don't want to read and write to the same file. It gets too complicated.
Last edited by WaltP; Oct 5th, 2006 at 3:25 pm.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,648
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1498
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: fwrite(size_t_count)

 
0
  #9
Oct 5th, 2006
Originally Posted by WaltP View Post
Actually, you read from one file, then write to another file. You don't want to read and write to the same file. It gets too complicated.

I did not suggest he write to the same file that he's reading. read the sudo-code again please -- "write to new file"
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,649
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: fwrite(size_t_count)

 
0
  #10
Oct 5th, 2006
Originally Posted by Ancient Dragon View Post
I did not suggest he write to the same file that he's reading. read the sudo-code again please -- "write to new file"
Actually Mr. WaltP did not direct his comment to you.
If you will read the OP recent post:
if i want to write to a file, do i have to fread it first or just
fwrite it straight away ?


Mr. WaltP's comment I think is directed to the OP.
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum


Views: 3884 | Replies: 19
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC