0

why this program is not work in %s and when I use %c it works .

Explain me please how this program works #include<stdio.h> int main() { char name[]="vikalp"; int i=0; while(name[i]){ printf("%s",name[i]); i++; } return 0; }

8th Nov 2021, 4:06 AM
Vikalp Monas
Vikalp Monas - avatar
3 ответов
+ 3
Because name[i] give a character so if you want to print character you have to use %c, %s is use when we require to print string .
8th Nov 2021, 5:07 AM
prashant kumhar
prashant kumhar - avatar
0
One more question I didn't give any. condition while using "while " loop I just gives a value zero to i and then how loop decide where to stop because last character is also null character in short I want to ask how this name[ i ] works ,can you tell entire process please
14th Nov 2021, 2:18 AM
Vikalp Monas
Vikalp Monas - avatar