Click here to Skip to main content
15,899,825 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralSaving graphical data in MDI Architecture Pin
laiju5-Apr-05 6:26
laiju5-Apr-05 6:26 
GeneralRe: Saving graphical data in MDI Architecture Pin
Alexander M.,5-Apr-05 8:05
Alexander M.,5-Apr-05 8:05 
Generaldisplay text when mouse is over a button Pin
wiselum5-Apr-05 6:06
wiselum5-Apr-05 6:06 
GeneralRe: display text when mouse is over a button Pin
Ravi Bhavnani5-Apr-05 6:57
professionalRavi Bhavnani5-Apr-05 6:57 
GeneralRe: display text when mouse is over a button Pin
wiselum5-Apr-05 19:56
wiselum5-Apr-05 19:56 
GeneralHorizontal Scrolling CRichEditView Pin
RobJones5-Apr-05 5:31
RobJones5-Apr-05 5:31 
GeneralRe: Horizontal Scrolling CRichEditView Pin
RobJones5-Apr-05 6:55
RobJones5-Apr-05 6:55 
Questionlinux segmentation fault strtok!? Pin
ThinkingPrometheus5-Apr-05 5:26
ThinkingPrometheus5-Apr-05 5:26 
hiho@ll

i know this site is for windows programming, but i just wanted to know if my C-Code could have a problem, and this website is very well visited i think

for those who also use linux:
i'm coding on a suse linux box with kernel 2.4.21-226-default running gcc v 3.3.1

the problem is a function named strtok
which tokenizes my string using a delimiter
char test[]="hallo hallo2";
z.B. first call strtok(test," "); // returns hallo
seconde call strtok(NULL," "); // returns hallo2

this code works!:
char str[] ="This is a sample string,just testing.";
char * pch;
printf ("Splitting string \"%s\" in tokens:\n",str);
pch = strtok (str," ");
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, " ,.");
}

this code doesn't work! (i get a segmentation fault):
char *str ="This is a sample string,just testing."; // just changed char[]
char * pch;
printf ("Splitting string \"%s\" in tokens:\n",str);
pch = strtok (str," ");
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, " ,.");
}

could there a problem with the code itself?
what's the difference between pointers and arrays?
i thought there is no difference!

thx@ll
AnswerRe: linux segmentation fault strtok!? Pin
David Crow5-Apr-05 5:58
David Crow5-Apr-05 5:58 
GeneralRe: linux segmentation fault strtok!? Pin
ThinkingPrometheus5-Apr-05 6:06
ThinkingPrometheus5-Apr-05 6:06 
GeneralRe: linux segmentation fault strtok!? Pin
David Crow5-Apr-05 6:19
David Crow5-Apr-05 6:19 
GeneralRe: linux segmentation fault strtok!? Pin
ThinkingPrometheus5-Apr-05 6:29
ThinkingPrometheus5-Apr-05 6:29 
GeneralRe: linux segmentation fault strtok!? Pin
David Crow5-Apr-05 6:38
David Crow5-Apr-05 6:38 
GeneralRe: linux segmentation fault strtok!? Pin
ThinkingPrometheus5-Apr-05 6:42
ThinkingPrometheus5-Apr-05 6:42 
GeneralRe: linux segmentation fault strtok!? Pin
Michael Dunn5-Apr-05 7:00
sitebuilderMichael Dunn5-Apr-05 7:00 
GeneralRe: linux segmentation fault strtok!? Pin
David Crow5-Apr-05 7:03
David Crow5-Apr-05 7:03 
GeneralRe: linux segmentation fault strtok!? Pin
ThinkingPrometheus5-Apr-05 7:19
ThinkingPrometheus5-Apr-05 7:19 
Generalproperty sheets apply event Pin
laiju5-Apr-05 4:07
laiju5-Apr-05 4:07 
GeneralRe: property sheets apply event Pin
David Crow5-Apr-05 4:11
David Crow5-Apr-05 4:11 
GeneralRe: property sheets apply event Pin
PJ Arends5-Apr-05 9:35
professionalPJ Arends5-Apr-05 9:35 
GeneralHiding the default MDI Child Pin
laiju5-Apr-05 3:58
laiju5-Apr-05 3:58 
GeneralRe: Hiding the default MDI Child Pin
YaronNir5-Apr-05 5:11
YaronNir5-Apr-05 5:11 
GeneralRe: Hiding the default MDI Child Pin
rgchezhian5-Apr-05 5:57
rgchezhian5-Apr-05 5:57 
GeneralRe: Hiding the default MDI Child Pin
laiju5-Apr-05 6:00
laiju5-Apr-05 6:00 
GeneralRe: Hiding the default MDI Child Pin
PJ Arends5-Apr-05 10:54
professionalPJ Arends5-Apr-05 10:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.