string help whats wrong with this code?
-
thanks i just got it!:)
i have just got an error wit the line: y=strchr(t,'}'); on running it i changed the code a bit to: char abc[1000]; char *Input; strcpy(abc,Input); char *t,*y; t=strrchr(abc,'{'); y=strchr(t,'}'); if(y) *y=0; cout << t+1; HidPass = t; does this have anything to do with it?
-
i have just got an error wit the line: y=strchr(t,'}'); on running it i changed the code a bit to: char abc[1000]; char *Input; strcpy(abc,Input); char *t,*y; t=strrchr(abc,'{'); y=strchr(t,'}'); if(y) *y=0; cout << t+1; HidPass = t; does this have anything to do with it?
You need to do one more pointer validity check.
char abc[1000];
char *Input; //better alloc some memory here
strcpy(abc,Input);
char *t,*y;
t=strrchr(abc,'{');
if (t) y=strchr(t,'}');
if(y) *y=0;
if(t) cout << t+1;
HidPass = t+1;//remember the plus one hereNish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org
-
You need to do one more pointer validity check.
char abc[1000];
char *Input; //better alloc some memory here
strcpy(abc,Input);
char *t,*y;
t=strrchr(abc,'{');
if (t) y=strchr(t,'}');
if(y) *y=0;
if(t) cout << t+1;
HidPass = t+1;//remember the plus one hereNish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org
sorry about all this but now it has a problem with HidPass = t+1;//remember the plus one here:(( :((
-
sorry about all this but now it has a problem with HidPass = t+1;//remember the plus one here:(( :((
Is HidPass declared as a char* and if so, has it been allocated some memory using new or malloc? By the way if the answer is "yes" to the above question replace that line with :- if(t) HidPass=t+1; Nish Nish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org
-
Is HidPass declared as a char* and if so, has it been allocated some memory using new or malloc? By the way if the answer is "yes" to the above question replace that line with :- if(t) HidPass=t+1; Nish Nish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org
i dont get any errors now it just does not work? HidPass does not equal anything?
-
i dont get any errors now it just does not work? HidPass does not equal anything?
hang on i know why thanks for your help
-
hang on i know why thanks for your help
Steven Richardson wrote: hang on Okay :-) Nish Nish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org
-
Steven Richardson wrote: hang on Okay :-) Nish Nish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org
you said char *Input; //better alloc some memory here how do i do that? and i know why it is not working! cos as soon as Input becomes a char it screws up and does not equal what it should?
-
you said char *Input; //better alloc some memory here how do i do that? and i know why it is not working! cos as soon as Input becomes a char it screws up and does not equal what it should?
Steven Richardson wrote: you said char *Input; //better alloc some memory here how do i do that? char *Input = new char[1024]; or char Input[1024]; Nish CPUA # 0x0666 Sonork ID 100.9786 voidmain www.busterboy.org
-
Steven Richardson wrote: you said char *Input; //better alloc some memory here how do i do that? char *Input = new char[1024]; or char Input[1024]; Nish CPUA # 0x0666 Sonork ID 100.9786 voidmain www.busterboy.org
Input cannot be made in to a char as it no longer equals what it should so as a AnsiString it equals: save that{ste} and as a char it equals:ÈóI