From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,8083a431078ea083,start X-Google-Attributes: gid1164f8,public From: nbehzad@ee.ualberta.ca (Nader Behzad) Subject: Segmentation Violation Date: 1996/11/06 Message-ID: <55qgbj$tdi@pulp.ucs.ualberta.ca>#1/1 X-Deja-AN: 194901613 organization: University of Alberta Electrical Engineering Department newsgroups: comp.sys.dec Hi all, Could anyone tell me if I am doing something wrong here or is it the compiler: char *tempstring; tempstring = (char *)Malloc(256*sizeof(char)); char_count = strlen(angle_file); tempstring = strrchr(angle_file, '/'); if (tempstring != NULL) { tempstring++; } i = (char_count - strlen(tempstring)); /* <-------- A */ strncpy(temp, angle_file, i); temp[i] = '\0'; "tempstring" is NULL and this causes the program to crash at point A. The strlen result for NULL should be 0 right?? I don't have this problem under SUN_OS or Solaris platforms. Thank you, Sincerely, Nader -- --------------------------------------------------------------------- | | | Nader T. Behzad | | e-mail: nbehzad@ee.ualberta.ca | | WWW: http://www.ee.ualberta.ca/~nbehzad | | | |===================================================================| | | | "Whatever you do will be insignificant, but it is very | | important that you do it." --Mahatma Gandhi | | | ---------------------------------------------------------------------