Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Simpel question in C (tcshell) about strings and pointers

  1. Jan 12, 2012 #1
    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 (Text):
    echo "Hello, World. bla bla bla" | program <arg>
    How can I save the string in my program before working on it?

    Thanks in advance
  2. jcsd
  3. Jan 12, 2012 #2


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Code (Text):

    char instring[40];
    where use 40 or whatever your max string length is. Your string is located at the address pointed to by the pointer instring.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook