Code:#include<stdio.h> void main(){ char ch;char s[]="Hello"; int loc; printf("Location\n"); scanf("%d",&loc); printf("Enter character to be entered \n"); scanf("%c",&ch); s[loc]=ch ; printf("%s",s); }
Code:#include<stdio.h> void main(){ char ch;char s[]="Hello"; int loc; printf("Location\n"); scanf("%d",&loc); printf("Enter character to be entered \n"); scanf("%c",&ch); s[loc]=ch ; printf("%s",s); }
What is the problem with your code?
You need to ask specific questions.
Jim
scanf("%d",&loc); left \n in the input stream
scanf("%c",&ch); read this character.
FAQ > Flush the input buffer - Cprogramming.com
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler