GCC - Input given from file is not displaying

Status
Not open for further replies.

raju39k

Newbie level 4
Joined
Apr 3, 2012
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,313
Hai

I am giving input to C program from a file and redirecting output to a file.

The input given from input file is not displayed in output file

I am using the following command


Code:
./AIQ1 < input.txt > output.txt

The following output is stored in output file

Code:
How many elements you want to insert:
Enter the element:
Enter the element:
Enter the element:
Enter the element:
Enter the element:
Enter the element:
Items in LinkedList:
96 85 74 14 36 25

The input file consist the following data
6

25 36 14 74 85 96

Please help to store the output as
Code:
How many elements you want to insert:6
Enter the element:96
Enter the element:85
Enter the element:74
Enter the element:14
Enter the element:36
Enter the element:25
Items in LinkedList:
96 85 74 14 36 25

Thanks in Advance
@Raju39k
 

Assuming you've access to the source code, then this is possible (at least in cygwin):

Code:
#include <stdio.h>
#include <unistd.h>

int
main(void)
{
  int n;
  printf ("Enter value:");
  scanf("%d", &n);
  if (isatty(STDIN_FILENO)==0)
    printf("%d\n", n);
  printf("Value was %d\n", n);
  return(0);
}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…