Help

This is a discussion on Help within the C++ Programming forums, part of the General Programming Boards category; I cant figure out how to use the atoi function.... So Maybe its not wht I need. How can I ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    16

    Help

    I cant figure out how to use the atoi function....
    So Maybe its not wht I need.

    How can I do this

    Code:
    int number;
    char string1[20];
    
    ifstream fin("file.dat");
    fin >> string1;
    
    if(number > string1) dofunction();
    See, string1 contains pure numbers, but it must be a char to get the info from file, right?


  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    if(number > atoi(string1)) dofunction();
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    16
    Thank you

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    148
    Why not read in an integer?
    Code:
    int number;
    int number_2;
    
    ifstream fin("file.dat");
    fin >> number_2;
    
    if(number > number_2) dofunction();

  5. #5
    Registered User
    Join Date
    May 2003
    Posts
    16
    oh.... Wow, I feel stupid.... Thank You!

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21