fwrite(size_t_count)

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

Join Date: May 2006
Posts: 3,131
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
  #11
Oct 6th, 2006
Originally Posted by ~s.o.s~ View Post
Actually Mr. WaltP did not direct his comment to you.
True. Thank you Mr. SOS for clearing that up in my absense.
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: 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
  #12
Oct 6th, 2006
Heheh :] wts happening here
wel
for each line in the source file

read a line <----------------------------- thats easy !

replace all commas with semicolons <--------- i'll try my best

write the string to the new file <------------- kinda of problem in here coz i have some int arrays example:
int cust_num;
char item[50];
int cost;

its easy to use fputs for the char item[50] but still struggling with int cust_num (conversion) i'll appreciate any help !
example:
fputs(rSales[i].cust_num,fpr);

1 more thing i tried to write rSales[i].cust_num using
fputc(rSales[i].cust_num,fpr);

but the problem that i'm getting some ASCII codes in fpr

end<------------Thx for help guyz
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)

 
0
  #13
Oct 6th, 2006
Convert cust_num to string for example with sprintf.
  1. char buff[MAX];
  2. sprintf(buff, "%d", cust_num);
  3. fputs(buff, fpr);
  4. /* and for fputc */
  5. fputc(cust_num + '0', fpr); /* suposing that cust_num is less than 10 and smalles 0 */
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
  #14
Oct 6th, 2006
Originally Posted by andor View Post
Convert cust_num to string for example with sprintf.
  1. char buff[MAX];
  2. sprintf(buff, "%d", cust_num);
  3. fputs(buff, fpr);
  4. /* and for fputc */
  5. fputc(cust_num + '0', fpr); /* suposing that cust_num is less than 10 and smalles 0 */
oi its WorkSSS :cheesy:
i have kinda of phobia from conversion ! do u know any good site for conversions !

thx mate :!:
DarkCoder+
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,662
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: 1502
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: fwrite(size_t_count)

 
0
  #15
Oct 6th, 2006
you don't really need sprintf at all. just use fprintf()
int cust_num = 123;
fprintf(fpr, "%d\n", cust_num); 
// now if you want the number to have at least 5 digits, with leading 0s when needed
fprintf(fpr, "%05d\n", cust_num);
Last edited by Ancient Dragon; Oct 6th, 2006 at 8:36 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
  #16
Oct 6th, 2006
that works fine mate !
any website about conversions ! i better get some knowledge !
cheers Champ
DarkCoder+
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,652
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
  #17
Oct 6th, 2006
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  
Join Date: May 2006
Posts: 3,131
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
  #18
Oct 6th, 2006
Originally Posted by rowly View Post
its easy to use fputs for the char item[50] but still struggling with int cust_num (conversion) i'll appreciate any help !
Where did this conversion come in? I thought you were reading each line and replacing , with ;. There should be no conversions anywhere.
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: 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
  #19
Oct 7th, 2006
Originally Posted by WaltP View Post
Where did this conversion come in? I thought you were reading each line and replacing , with ;. There should be no conversions anywhere.
wel waltP, i'm doing two programs in the 1st one i have to read from a csv file and eliminate the ","
s1.csv contents:
2,Ajle,1999999,235.6,6
3,ksiSeal,1062230,222.8,2
...
...
...
the second program is reading from the same file s1.csv and and write it to a new *.txt file with replacing the delimiter "," with a delimiter ";" and by doin some ascending sort....
example *.txt contents:
2;Ajle;1999999;235.6;6
3;ksiSeal;1062230;222.8;2
...
...
...
and we have a fix struct in both programs so thats why i was doin conversion !

Anyways i'm bout to finish it all still have the sort part and bang finish !
thx alote guyz
DarkCoder+
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
  #20
Oct 7th, 2006
sorry bout na postin the programs , i'm uni student and for sure i'll get a good circle if somebody copy It.
DANIWEB is wide opened on google and yahoo ! :p so everyone in ma class will have the same code ! hahah
cheers mate !
:]
DarkCoder+
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: 3895 | 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