-
Junior Member
Re: What am I doing wrong? Please help
i think you are checking the condition after incrementing index , a for loop is essentially :
for (expr1; expr2; expr3)
statement
is equivalent to
expr1;
while (expr2) {
statement
expr3;
}
hence you are reading into ch[index] while checking for condition at ch[index+1) , try the following :
do
{
scanf("%c", &ch[index]);
printf("\n%c", ch[index]);
}while( ch[index++] != '\n');
it should work
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules