Intel® FPGA University Program
University Program Material, Education Boards, and Laboratory Exercises
1196 Discussions

how to use getch in niosII

Altera_Forum
Honored Contributor II
1,788 Views

hi i want to ask what is the header file to add for using getch in niosII. I had try to add conio.h but it say that No such file or directory.  

thx for helping:)
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
863 Views

getch() and <conio.h> aren't standard C. You can use getchar() (http://sourceware.org/newlib/libc.html#getchar) instead (that you'll find in <stdio.h>)

0 Kudos
Altera_Forum
Honored Contributor II
863 Views

but getchar is different function with getch o

0 Kudos
Altera_Forum
Honored Contributor II
863 Views

What you want to achieve with this getch()? 

How does the getchar() gon't suite your need? 

 

May be you can post your code here?
0 Kudos
Altera_Forum
Honored Contributor II
863 Views

Yes, now i trying to use getchar() but there still some problem with it because i using "string" to do it but when i change to "int" or "char" it can be done. The problem is when i using string the password that i type out is correct (i already prove by typing: printf (%s, &password) ) but it still cant be match with the password that i had set. I making a program that need to type password to log in, when typing password those character will become ***, by the way i still dun know the programming change to *** is correct or not. Thx for helping 

 

my coding show as below:# include <stdio.h># include <stdlib.h># include <unistd.h># include <string.h> 

 

void one(); 

void two(); 

int login ;  

int user ; 

char password[10]; 

int i = 0; 

char c; 

 

 

int main () 

while(1){ 

printf ("---------------------------\n"); 

printf (" Main Menu\n"); 

printf ("----------------------------\n"); 

printf (" 1.Admin login\n 2.User login\n"); 

scanf("%i", &login); 

if (login == 1) 

two(); 

if (login == 2) 

printf ("Display\n"); 

 

return(0); 

 

void one() 

{  

menu: 

printf ("---------------------------\n"); 

printf (" User Menu\n"); 

printf ("----------------------------\n"); 

printf (" 1.Check User\n 2.Delete User\n 0.Main Menu\n"); 

scanf("%i", &user); 

if (user == 1) 

printf ("CHECK\n"); 

else if (user == 2) 

{  

printf ("DELETE\n");  

 

else if (user == 0) 

main (); 

 

else if (user != 1,2,0) 

printf ("Wrong key please retry\n"); 

goto menu; 

 

else  

NULL;  

 

void two() 

printf ("Please enter password: "); 

enter: 

scanf("%s", &password); 

{  

while(i<5){ 

c = getchar(); 

 

password = c; 

printf("*"); 

i++; 

getchar(); 

i=0; 

while (i<5) 

printf("%c",pass); 

i++;  

getchar(); 

if (password == 'obc') 

one();  

 

else if (password != 'obc')  

printf ("Wrong password, please retype "); 

goto enter; 

 

else  

NULL; 

 

 

ps: previously those getchar i use getch for it
0 Kudos
Reply