Thread: read unknown integers from text file

  1. #1
    Registered User
    Join Date
    Nov 2009

    read unknown integers from text file

    i have made a small encyption program nothing fancy really. it turns the letters into 6-9 digit long number seperating each with a \n

    i now need to read in each numbers so i can reverse the calculation for the decyrpt but cant seem to work out how to read the number from the text file "output.txt" and store ir as an int so i can preform calculation on it.

    i need to do this in c NOT C++ AND NOT C#

    if anyone can help id really appriciate it. i tryed using fgetc and concatonating the chars togethers and atio them but coudnt get it to work.

  2. #2
    Registered User rpbear's Avatar
    Join Date
    Nov 2009
    try the code below
    	FILE* fin = fopen("d:\\a.txt","r");
    	long ld = 0;
    	while(fscanf(fin,"%ld\n",&ld) == 1)
    	return EXIT_SUCCESS;

  3. #3
    Registered User
    Join Date
    Sep 2006
    At some point, aren't you going to be hexed by the encryption program giving you "numbers" that are preceded by zero's, like: "003569"?

    How are you going to handle it in your program?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [HELP] Read text file in vc++ 2005
    By sonnb in forum C++ Programming
    Replies: 1
    Last Post: 05-12-2007, 10:01 AM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Replies: 5
    Last Post: 02-01-2003, 10:58 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

Tags for this Thread