Simpel question in C (tcshell) about strings and pointers

1 reply · 2K views · last reply
ydan87
Messages
25
Reaction score
0
If I need to write a c program which get a string from the stdin and prints it after a certain manipulation, the program is called that way:
Code:
echo "Hello, World. bla bla bla" | program <arg>
How can I save the string in my program before working on it?

Thanks in advance
 
Try
Code:
char instring[40];
fscanf(stdin,"%s",instring):
where use 40 or whatever your max string length is. Your string is located at the address pointed to by the pointer instring.