How to input a characters with for loop in C

1 Answer

0 votes
#include <stdio.h>
 
int main(void)
{
    int ch;
    
    for (int i = 0; (ch = getchar()) != '\n' && ch != EOF; i++) 
         putchar(ch);

    return 0;
}



/*
run:

c programming
c programming

*/

 



answered Nov 4, 2015 by avibootz

Related questions

1 answer 157 views
1 answer 81 views
81 views asked May 10, 2023 by avibootz
2 answers 177 views
177 views asked Sep 21, 2021 by avibootz
2 answers 206 views
...