Thread: Text file

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    4

    Question Text file

    Hey I need help to define variable when numbers are in a text file.

    What I need to do is:
    Open a text file that there is only one line, its write: 1000,0.15,5

    I need to read the line and define the variable:
    1000 as 'float money'
    0.15 as 'float interest'
    5 as 'int month'

    There is my code so far

    Code:
    	
    	float money;
    	float interest;
    	int Month;
    
    	FILE *fEntree;
    
    	fEntree = fopen("infobase.DON","rt");
    	if  (fEntree == NULL)
    		printf("Error");
    
           /* need the code there */
    
    	fclose(fEntree);
    Thanks to anyone who help

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Look into using the fscanf() function (or a mixture of fgets() and sscanf()).
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  3. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  4. checking values in a text file
    By darfader in forum C Programming
    Replies: 2
    Last Post: 09-24-2003, 02:13 AM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM