943,740 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Marked Solved
  • Views: 4423
  • C RSS
You are currently viewing page 1 of this multi-page discussion thread
Oct 5th, 2006
0

fwrite(size_t_count)

Expand 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);

Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
rowly is offline Offline
65 posts
since Sep 2006
Oct 5th, 2006
1

Re: fwrite(size_t_count)

Click to Expand / Collapse  Quote originally posted by rowly ...
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.
Reputation Points: 251
Solved Threads: 29
Posting Whiz in Training
andor is offline Offline
274 posts
since Jun 2005
Oct 5th, 2006
0

Re: fwrite(size_t_count)

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
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
rowly is offline Offline
65 posts
since Sep 2006
Oct 5th, 2006
0

Re: fwrite(size_t_count)

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,950 posts
since Aug 2005
Oct 5th, 2006
0

Re: fwrite(size_t_count)

aha !
if i want to write to a file, do i have to fread it first or just
fwrite it straight away ?
thx champ



Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
rowly is offline Offline
65 posts
since Sep 2006
Oct 5th, 2006
0

Re: fwrite(size_t_count)

Quote ...
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?
Reputation Points: 53
Solved Threads: 6
Junior Poster in Training
Inanna is offline Offline
90 posts
since Sep 2006
Oct 5th, 2006
0

Re: fwrite(size_t_count)

Click to Expand / Collapse  Quote originally posted by rowly ...
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
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,950 posts
since Aug 2005
Oct 5th, 2006
0

Re: fwrite(size_t_count)

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.
Moderator
Reputation Points: 3278
Solved Threads: 891
Posting Sage
WaltP is offline Offline
7,718 posts
since May 2006
Oct 5th, 2006
0

Re: fwrite(size_t_count)

Click to Expand / Collapse  Quote originally posted by WaltP ...
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"
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,950 posts
since Aug 2005
Oct 5th, 2006
0

Re: fwrite(size_t_count)

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:
Quote ...
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.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: qt3 designer help
Next Thread in C Forum Timeline: help required!!!!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC