Questions:
1) What is the difference between "puts" and "printf" functions in C programming? Write a program to show the difference.
2) Why is the "getch()" function in C not working?
Answers
Answered by
3
Answer:
1) printf prints whatever you provide, it may be text, text + values etc without adding new line after the text while puts add one more character that is new line character (\n) just after the text/character stream.
2) getch() is a nonstandard function and is present in conio.h header file which is mostly used by MS-DOS compilers like Turbo C. It is not part of the C standard library or ISO C, nor is it defined by POSIX.
Like these functions, getch() also reads a single character from the keyboard. But it does not use any buffer, so the entered character is immediately returned without waiting for the enter key.
Answered by
1
- printf prints whatever you provide, it may be text, text + values etc without adding new line after the text while puts add one more character that is new line character (\n) just after the text/character stream.
- #include <stdio.h>
#include <conio.h>
int main(void){
char str[] = "This is the end";
printf("%s\n", str);
getch(); //I tried getchar() also still does not work
return 0;
Similar questions
India Languages,
1 month ago
Math,
1 month ago
Math,
2 months ago
Physics,
9 months ago
Math,
9 months ago