954,190 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Storing file input to an array?

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.

Savage221
Newbie Poster
20 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

Did you tried with fgets ? For help read this

andor
Posting Whiz in Training
276 posts since Jun 2005
Reputation Points: 251
Solved Threads: 29
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You