C Program to Take String Input From User on Command Line Using getch() Function

In this article, You are going to know about C Program to Take String Input From User on Command Line Using getch() Function. Let’s move on to the article to do this task below.

C Program to Take String Input From User on Command Line Using getch() Function

C Program to Take String Input From User on Command Line Using getch() Function

Source Code

#include <stdio.h>   
#include <conio.h>   
int main() {      
    char ch[6] = {0}; int x;  
    for ( x = 0; x < 5; x++) {  
        ch[x] = getch(); // getch() function to take input  
    }  
    printf("Received 5 character Input: %sn", ch);  
    return 0;  
}

Conclusion

That’s it. I hope this article helps you to know about “C Program to Take String Input From User on Command Line Using getch() Function“. If you have to face any issues then comment down. I will help you. Share this article with other C/C++ developers.

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment