Error Following Program Block Related C Programming String Topics Char X Scanf S X Q37067850

What is the error in the following program block? ( which isrelated C programming on string topics)

char *x;

scanf(“%s”, x);


Answer


In the given question

char *x;

scanf(“%s”,x);

As per the question,you said that the block is related to stringconcepts…

In string concepts we can define char in 4 types,below isthere

1.char str[] = “chegg”

2. char str[50] = “chegg”

3. char str[] = {‘c’,’h’,’e’,’g’,’g’,”};

4. char str[14] = {‘c’,’h’,’e’,’g’,’g’,”};

in the question,

char *x;

scanf(“%s”,x);

that is char *x  defined in pointer …that’s alsowrong char* x…in the char we can assiagn some value ,string

example

char* x=”chegg”;

scanf(“%s”,x);

printf(x);

THANK YOU…..

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.