Print string character by character
C program to print string one by one characters using loop.
Program
#include<stdio.h>
#include<conio.h>
#define MAx 50
void main()
{
char str[MAX], ch;
int i;
printf("Enter the string\t:");
for(i=0;i<MAX;i++)
{
ch = getche();
if(ch == 13)
{
break;
}
str[i] = ch;
}
str[i] = '\0';
printf("\nYou have entered\t:");
for(i=0;str[i]!='\0';i++)
{
printf("%c",str[i]);
}
getch();
}
Output
Enter the string :welcome to coursecrux.com
You have entered :welcome to coursecrux.com