Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tlug: gcc question



Pardon me if this question is inappropriate for this list, but after
following it for several months, I thought someone might have a ready
answer.

I'd like to continue to use gcc and xxgdb for some C classes I've
been taking, but I seem to have encountered a difference in how gcc
handles * char compared with how the MSVC++ compiler handles it.  An
example is the code fragment below. gcc gives me a segmentation error when
it runs, while MSVC++ doesn't.   Apparently the problem occurs when gets()
tries to access *lname at 0x0.  I suppose there must be  a good reason for
this.  Can anyone tell me what it is and tell me how I should be handling
it?

Thank you for any insight.

Drew Poulin


#include<stdio.h>


main(){
  
  char *fname, *lname;
 
  puts("Enter fname:\n");
  gets(fname);
  puts("Enter lname:\n");
  gets(lname);
 printf("First name: %s\tLast name: %s\n", fname, lname);

}


-------------------------------------------------------------------
Next Technical Meeting: January 14 (Fri) 19:00
* Topic: "glibc - current status and future developments"
* Guest Speaker: Ulrich Drepper (Cygnus Solutions)
* Place: Oracle Japan HQ 12F Seminar Room (New Otani Garden Court)
-------------------------------------------------------------------
more info: http://www.tlug.gr.jp        Sponsor: Global Online Japan


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links