Simpel question in C (tcshell) about strings and pointers

  • Thread starter Thread starter ydan87
  • Start date Start date
  • Tags Tags
    Pointers Strings
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
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
 
Physics news on Phys.org
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.