This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
scanf, linux and solaris
- To: gcc-help at gcc dot gnu dot org
- Subject: scanf, linux and solaris
- From: "david smith" <nextl at angelfire dot com>
- Date: Wed, 06 Jun 2001 06:50:06 -0700
- Organization: Angelfire (http://email.angelfire.mailcity.lycos.com:80)
- Reply-To: nextl at angelfire dot com
Hi, I've been trying to scan in a string using scanf. The following code works fine on Solaris but breaks on Linux(tested on two different boxes) with a seg fault. Currently it breaks when the username is longer than 10 chars, on a previous attempt before rebooting it would break when the username was longer than 6 chars.
Any help would be appreciated.
#include <stdio.h>
main(){
char* username;
printf("Username:");
scanf("%s", &username);
}
Get 250 color business cards for FREE!
http://businesscards.lycos.com/vp/fastpath/