btocakci
asked on
pointer arrays
Hi! im trying to use one of the elements of an pointer array like *ptrarray[10] in strcopy function..
....
atomptr=strtok(string,"");
for(i=0;i<10;i++){
strcpy(ptrarray[i],atomptr );
atomptr=strtok(NULL;"");}
my goal is to put all of the atoms of a string into seperate strings..
....
but it doesnt run..What is the mistake here?..
....
atomptr=strtok(string,"");
for(i=0;i<10;i++){
strcpy(ptrarray[i],atomptr
atomptr=strtok(NULL;"");}
my goal is to put all of the atoms of a string into seperate strings..
....
but it doesnt run..What is the mistake here?..
ASKER
"proje.exe has encountered with a problem and must be closed.." sayin window was opened and program was closed..
ASKER
i encounter with no errors or warnings in microsoft Visual studio compiler..
Hi btocakci,
This sounds like you are accessing some memory which you should be accessing or there is some logical error.
If the code is small, post it here and we will have a look at it. If the code is huge, try to run it through a debugger or place prints at several places to find out where the error is occuring
Cheers!
sunnycoder
This sounds like you are accessing some memory which you should be accessing or there is some logical error.
If the code is small, post it here and we will have a look at it. If the code is huge, try to run it through a debugger or place prints at several places to find out where the error is occuring
Cheers!
sunnycoder
ASKER
atomptr=strtok(string,sep) ;
i=0;
while((strcmp(atomptr,from ))){
printf("%s\n\n",atomptr);
atomptr=strtok(NULL,sep);
strcpy(selectarraytemp[i], atomptr);
i++;
}
strcpy(selectarraytemp[0], talha);
want to put this atoms into strings while the word "from" encountered. May tyhere be any infinite loops?
i=0;
while((strcmp(atomptr,from
printf("%s\n\n",atomptr);
atomptr=strtok(NULL,sep);
strcpy(selectarraytemp[i],
i++;
}
strcpy(selectarraytemp[0],
want to put this atoms into strings while the word "from" encountered. May tyhere be any infinite loops?
ASKER
of course i wrote char*from="from" at the beginning..
have you initilized ptrarray's elements to point to some char[] array memory?
ASKER
i think i dont know how to do this?!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
really thanks sunnycoder, i have really much to learn from you..
error C2440: '=' : cannot convert from 'void *' to 'char *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
on the line : selectarraytemp[i] = malloc (strlen(atomptr)+1);
what may be the problem?
error C2440: '=' : cannot convert from 'void *' to 'char *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
on the line : selectarraytemp[i] = malloc (strlen(atomptr)+1);
what may be the problem?
Try to use the hints in error messages and warnings to determine what the problem might be ;)
selectarraytemp[i] = (char *)malloc (strlen(atomptr)+1);
selectarraytemp[i] = (char *)malloc (strlen(atomptr)+1);
ASKER
You will really teach me how to code in c by just yourself i think..Really thanks..
Glad to help :)
> atomptr=strtok(NULL;"");}
there should be a comma (,) and not semi-colon between NULL and ""
atomptr=strtok(NULL,"");}
> but it doesnt run..What is the mistake here?..
What are the errors? Does the above rectify them?
Cheers!
sunnycoder