Reading a signed integer from a file in C

-1

I have to read " -10899 "(and many more integers) from a text file into an integer variable in C.

This is what I have so far:

int i = 0;
    // get data from file and convert to int
    for(; i < (2 * (_sym * (_roll_off + _symbol_len))) && fgets(ifft_out, 12, fp) != NULL; i++ )
    {
       a = atoi(ifft_out);
       a &= 0xFFFFFFFF;
       ifft_data[i] = a;
    }

It reads as "-9083" into the variable, not sure whats wrong here.

P.S: ifft_out is a char

c
arrays
file
fgets
asked on Stack Overflow Oct 15, 2019 by samz12

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0