Storing file input to an array?

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

Join Date: Oct 2005
Posts: 20
Reputation: Savage221 is an unknown quantity at this point 
Solved Threads: 0
Savage221 Savage221 is offline Offline
Newbie Poster

Storing file input to an array?

 
0
  #1
Nov 2nd, 2006
Hello, well, as the title states, I need to take the file input and store it into a string. It seems simple enough, just setup a for loop going through the total number of characters in the file input, or just do a while !EOF loop, the part I'm not sure about is the code that actually stores the values into the string. Using scanf or fscanf leaves out blank spaces and new lines, so the printed output doesn't match the file input properly.

How do I go about this? declaring a file pointer and then setting that to fopen and the filename works fine, and printing directly from the input works as well, but I need to store the input into a string and manipulate it from there. Any and all help is as always appreciated. Thanks everyone.
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: Storing file input to an array?

 
0
  #2
Nov 2nd, 2006
Did you tried with fgets? For help read this
If you want to win, you must not loose (Alan Ford)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC