
The last one indicates we need one new line character to denote end of string. Here the first parameter is string, second is the size and last one is stdin to take input from console. Your program sometimes does not wait for next input, so we need to clear the buffer using fflush(stdin)Īnd for string with spaces we need to use fgets() function.

Your IDE will usually have a compiler built in, but many (including Code::Blocks and Netbeans) require a compiler like GCC to compile programs.If youre using Linux, you have the best compiler already built inGCC. This step is optional, but required in some cases. A compiler turns the code you write into a program you can run. To solve this, we will follow these steps −įor character we need to use scanf("%c", &character) įor string we need to use scanf("%s", string) Your sentence: I love programming through C Then the output will be Your character: T Sentence = "I love programming through C",

The maximum size of the string is 500 here.

So we shall provide three inputs and print the same as output. Suppose you want to take a character, then a string and a sentence (string with spaces) using C.
