input problem

How can we enter an expression in c

Expression of what ? If its of characters, then you can use the gets() function to input.
for eg :

char input[size_of_expression];  // initialise a character array of required size to hold the expression
gets(input);                    // inputs the expression 

You can also use scanf() with ā€œ%sā€ as control string to read but the scanf() function stops reading after a blank space occurs in the expression. So if you have to input an expression like Hello world - it will read only Hello.

1 Like