- Reads String Character by Character
Syntax for Accepting String :
- ch = getchar(); // getchar accepts character & stores in ch
Example :
- ch = getchar() ;
- name[0] = getchar();
Live Example : : For Accepting String (Use One of the Loop)
#includevoid main() { int i = 0; char name[20]; printf("\nEnter the Name : "); while((name[i] = getchar())!='\n')) i++ ; getch(); }
Rules / Facts :
- getchar accepts string Character by character
- Terminating Condition Should be specified
- Here Terminating Condition is : \n (i.e Loop will be continue until new line character is entered )

0 Comments:
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email