c - Scanf two numbers at a time from stdout -


i have program outputs huge array of integers stdout, each integer in line. ex:

103 104 105 107 

i need write program reads in array , fill spaces number isn't increment of 1 of previous number. different between numbers going 2 (105,107), makes easier.

this code logic:

printf("d",num1);  if ((num2-num1) != 1)     numbetween =  num1 + 1;     printf("%d", numbetween);     printf("%d", num2); else(     printf("%d",num2); ) 

so output of program be:

103 104 105 106 107 

my issue reading numbers. know can while (scanf("%hd", &num) != eof) read lines 1 @ time. logic want, i'm going need read 2 lines @ time , computation them, , don't know how.

you read first , last numbers file, , print in between.

int main( void ) {     // first value in file     int start;     if ( scanf( "%d", &start ) != 1 )         exit( 1 );      // last value in file     int end = start;     while ( scanf( "%d", &end ) == 1 )         ;      // print list of numbers     ( int = start; <= end; i++ )         printf( "%d\n", ); } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -