-6

Is there a C function used to read characters from keyboard that does not return newlines ?

I have tried getchar() and scanf() .But both of it failed.

Please tell me if there is a function.

Arun A S
  • 6,421
  • 4
  • 29
  • 43
Vipin
  • 1
  • 2

1 Answers1

-1

scanf() receives until a spacebar is entered ie.only one string is accepted . This can be overcome by using

scanf("%[^\n]s",str);.

It waits until newline is entered. gets() is also an alternative to receive string until newline is entered.

Nerdy
  • 1,016
  • 2
  • 11
  • 27