Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
For now, we will just input and output text and not do text processing.
2. String input and echo
Below is a simple C program to do string input and output. Note the following.
The length of strings is chosen as 256 since C does not provide for dynamic length strings.
In this course (unless otherwise specified), strings will always be read at the end of a line of input. The specifier "%[^\n]s" means to read the string until the end of the line. Otherwise, the first space would terminate that string.
Here is the C code.
3. Examples of input and output
Here are some examples of input and output for the above program code.
Here is an example input.
For the above example input, here is the expected output.
Here is an example input.
For the above example input, here is the expected output.
4. Mixed input types
The following C program shows how to input an integer followed by a text string. Note the following.
In the format string "%d " there is a space character after the "%d". That space character "eats" the space in the input. Otherwise, that space character would appear in the string (and in the output().
Here is the C code.
5. Examples of input and output
Here are some examples of input and output for the above program code.
Here is an example input.
For the above example input, here is the expected output.
Here is an example input.
For the above example input, here is the expected output.