C
Carramba
hi!
Iam trying to make program were I enter string and serach char.
and funktion prints out witch position char is found this
is done if funktion serach_char. so far all good
what I want do next is:
return, from funktion, pointer value to array were
positions ( of found char) is stored. and print that array from main.
but I only manage to print memory adress to array..
any suggestions?
so far everything works fine.
int search_char( char *pStr , char *pSearch );
int main(void){
char cStr[201];
char cSearch[21];
int *pInt;
int i ;
printf("Enter string\n",lillae);
scanf("%s", cStr);
printf("Enter char to sertch\n");
scanf("%s", cSearch);
*pInt = search_char( &cStr , &cSearch );
printf("Main prints here:\n");
for(i=0;i<20;i++){ //<== here problem starts
printf("%d\n",&pInt);
return 0;
}
int search_char( char *pStr , char *pSearch ) {
printf("Funktion prints here:");
int i;
int vPossition[201];
for( i=0;i<=200;i++){
if(pStr == pSearch[0]){
printf("Found %c in possition %d \n", pStr,i+1);
vPossition = i; //<== here problem starts ????
}
}
return vPossition;//<== here problem starts ???
}
--
Thanx in advance
________________________
BTW. I know my english is not best in the word, so please stop bugging me
about my speling. And yes Iam sorry you don't understand what I mean, but
there is no point to yell at me. Have a nice day.
Iam trying to make program were I enter string and serach char.
and funktion prints out witch position char is found this
is done if funktion serach_char. so far all good
what I want do next is:
return, from funktion, pointer value to array were
positions ( of found char) is stored. and print that array from main.
but I only manage to print memory adress to array..
any suggestions?
so far everything works fine.
int search_char( char *pStr , char *pSearch );
int main(void){
char cStr[201];
char cSearch[21];
int *pInt;
int i ;
printf("Enter string\n",lillae);
scanf("%s", cStr);
printf("Enter char to sertch\n");
scanf("%s", cSearch);
*pInt = search_char( &cStr , &cSearch );
printf("Main prints here:\n");
for(i=0;i<20;i++){ //<== here problem starts
printf("%d\n",&pInt);
return 0;
}
int search_char( char *pStr , char *pSearch ) {
printf("Funktion prints here:");
int i;
int vPossition[201];
for( i=0;i<=200;i++){
if(pStr == pSearch[0]){
printf("Found %c in possition %d \n", pStr,i+1);
vPossition = i; //<== here problem starts ????
}
}
return vPossition;//<== here problem starts ???
}
--
Thanx in advance
________________________
BTW. I know my english is not best in the word, so please stop bugging me
about my speling. And yes Iam sorry you don't understand what I mean, but
there is no point to yell at me. Have a nice day.