Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using stdio.h to input from a file

Status
Not open for further replies.

slim150

Programmer
Nov 5, 2004
1
US
Hello everyone, I am currently working on a project and have decided to write it in C for a change. One of the requirements for the project is given a .txt file with integers seperated by a space, input then into the program and so on. Normally I would use FSTREAM to get the values from a text file but I cannot because << isn't overloaded etc.

I was looking in some of the functions that stdio.h has and these two seemed promising fgetc and getw. However when I use fgetc I only grab the ascii character values of the numbers and spaces, which would be okay except that say i have the number 23, first it grabs the 2, then the 3, so I cant preform a simple subtraction to get the actual number. and I am not sure how to use getw it doesn't seem to work well for me.


Does anyone have any ideas how I can grab integers from a .txt file without using FSTREAM?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top