Can you tell me what is wrong with this code include includ
Can you tell me what is wrong with this code .
#include <stdio.h>
#include <ctype.h>
int main()
{
char line[100];
printf(\"Enter a line of text: \");//Prompts for a string.
scanf_s(\"%[^\ ]s\", line);//Reads a string, terminated by a new line.
printf(\"Original String: %s\ \", line);//Prints the original string.
int i = 0;
printf(\"Upper case String: \");
while (line[i] != \'\\0\')//For each character in the original string.
printf(\"%c\", toupper(line[i++]));//Prints its upper case equivalent character.
printf(\"\ \");//Move on to the next line.
i = 0;
printf(\"Lower case String: \");
while (line[i] != \'\\0\')//For each character in the original string.
printf(\"%c\", tolower(line[i++]));//Prints its lower case equivalent character.
printf(\"\ \");//Move on to the next line.
}
Solution
Answer
error is at line scanf_s(\"%[^\ ]s\", line);//Reads a string, terminated by a new line.
made it as
scanf(\"%[^\ ]s\", line);
Solution.c
#include <stdio.h>//header file for input output function
#include <ctype.h>//Header file \"ctype.h\" includes numerous standard library functions to handle characters
int main()
{// main function
char line[100];
printf(\"Enter a line of text: \");//Prompts for a string.
scanf(\"%[^\ ]s\", line);//Reads a string, terminated by a new line.
printf(\"Original String: %s\ \", line);//Prints the original string.
int i = 0;
printf(\"Upper case String: \");
while (line[i] != \'\\0\')//For each character in the original string.
printf(\"%c\", toupper(line[i++]));//Prints its upper case equivalent character.
printf(\"\ \");//Move on to the next line.
i = 0;
printf(\"Lower case String: \");
while (line[i] != \'\\0\')//For each character in the original string.
printf(\"%c\", tolower(line[i++]));//Prints its lower case equivalent character.
printf(\"\ \");//Move on to the next line.
}
output
Enter a line of text: Jhon Bush
Original String: Jhon Bush
Upper case String: JHON BUSH
Lower case String: jhon bush
![Can you tell me what is wrong with this code . #include <stdio.h> #include <ctype.h> int main() { char line[100]; printf(\ Can you tell me what is wrong with this code . #include <stdio.h> #include <ctype.h> int main() { char line[100]; printf(\](/WebImages/21/can-you-tell-me-what-is-wrong-with-this-code-include-includ-1048169-1761545508-0.webp)
![Can you tell me what is wrong with this code . #include <stdio.h> #include <ctype.h> int main() { char line[100]; printf(\ Can you tell me what is wrong with this code . #include <stdio.h> #include <ctype.h> int main() { char line[100]; printf(\](/WebImages/21/can-you-tell-me-what-is-wrong-with-this-code-include-includ-1048169-1761545508-1.webp)