+ 3
why I am unable to run the scanf() function in c?
it is not running in the c programming language. I am unable to understant how so plzz tell me about that.
15 Answers
+ 6
Hey Archit Kar
Use address-of operator (&) to store variable !
Ex: scanf("%c",&firstname);
+ 4
You need to store the name in an array of chars.
+ 3
Mahmoud 'Carbon' Saghraoui are you sure about that char[] declaration? I think it has to have fixed size, so you must declare size of that array, or make char pointer to allocate memory dynamically
+ 2
Show your code to find error and help you with perfect solution👍
+ 1
it does, please post your code
+ 1
Using sololearn app? 😢
+ 1
correct, what output did you expect?
+ 1
I don't see any mistakes there, you may not understand your own code so let me explain it for you.
-----------------------------
char firstname[]; <-- Declared a variable, i've added the '[]' keep 'em
printf("what is your name? \n"); <-- This prints 'what is your name'
scanf("%s", firstname); <-- Takes the input of the server
-----------------------------
If you want to print the name after the input was taken then you can do
printf("Your first name is: %s", firstname);
+ 1
ok thanks
+ 1
include header file...
#include<stdio.h>
+ 1
If still it's not working plzz send the codes!!
+ 1
thnx bro
0
my code is:-
char firstname;
printf("what is your name? \n");
scanf("%s", firstname);
but the output is coming.
what is your name?
0
used may not used the library function stdio.h