PDA

View Full Version : Installing NCurses



rgcouto
March 21st, 2008, 04:38 PM
Hello, I've installed ncurses on my ubuntu, but when I use the library "conio.h" or "ncurses.h" and compile my code with GCC, it returns me a strange error :/


/tmp/ccY6BDyH.o: In function `main':
main.c:(.text+0x201): undefined reference to `stdscr'
main.c:(.text+0x209): undefined reference to `wgetch'
collect2: ld returned 1 exit status


Do you know whats happening?


P.S. - Sorry about my bad english..

WW
March 21st, 2008, 06:10 PM
What was the command that you used to compile and link your code?

You might not have told the compiler to use the ncurses library. You probably have to add an option like -lcurses.

rgcouto
March 21st, 2008, 06:19 PM
What was the command that you used to compile and link your code?

You might not have told the compiler to use the ncurses library. You probably have to add an option like -lcurses.

Yeah ;) thx ... i've forgotten to call it when i compile....

rgcouto
March 21st, 2008, 10:27 PM
Now i have an other problem ;/ OMG

I have this code:




#include <stdio.h>
#include <conio.h>

...

char user[40], pwd[10], c;
int i = 0;

...

printf ("User Login\n");
printf ("Insert your username:\n");
fgets(user,50,stdin);
printf ("Insert your password:\n");
while (i <= 10) {
c = getch();
pwd = c; i++;
printf("*");
}

...

Then I have a function to test the login that returns "Hello, [i]username" or "Autentication failed"



but when I compile e run it the programm waits for insert the username, but when I <enter> it returns me:


***********Autentication failed!!
*** stack smashing detected ***: ./a.out terminated
Aborted (core dumped)


What's happening now?!?

I getting crazy with this error.. LOOL :P

supirman
March 22nd, 2008, 12:21 AM
See a problem?

char user[40], pwd[10], c;

fgets(user,50,stdin);

supirman
March 22nd, 2008, 12:27 AM
See what happens when I enter > 40 characters as the name:


$)> ./a.out
Enter you name: aaaassssddddffffddddssssddddffffddddssssddd
user is aaaassssddddffffddddssssddddffffddddssssddd

*** stack smashing detected ***: ./a.out terminated
Aborted (core dumped)


I'm sure you can see the problem from the previous post. If you don't know what's going on, feel free to ask for clarification.

rgcouto
March 27th, 2008, 05:27 PM
I've changed the code now:




#include <stdio.h>
#include <conio.h>

...

char user[40], pwd[10], c;
int i = 0;

...

printf ("User Login\n");
printf ("Insert your username:\n");
fgets(user,40,stdin);
printf ("Insert your password:\n");
while (i <=9) {
c = getch();
pwd = c; i++;
printf("*");
}

...

Then I have a function to test the login that returns "Hello, [i]username" or "Autentication failed"



and now when i compile, run, and insert the username it returns me:


***********Autentication failed!!

I'm close to freak out... GRRRRR ..[/QUOTE]

supirman
March 27th, 2008, 10:45 PM
How are you comparing the password? Are you using a strcmp? You're filling character by character into the password buffer, but I don't see you manually adding a terminating \0 to the password buffer to allow it to be treated as a string.