I have made a program in which I'm trying to return the string in
which the character is found.
I'm doing this through pointers. I'm not able to figure out the
correct way:
printf("%s", *string);
while(string != '\0')
{
printf("this is a test");
s = *string;
if(s == w)
{
printf("%c", s);
return (s1);
break;
}
*string++;
Please can some body help me
This is my code : -
#include <stdio.h>
#include <conio.h>
char *xstrchr(char *, char);
void main()
{
char a ='t';
//printf("%c", a);
char b[][8] = {"Scope", "Rule", "Now", "Testing"};
int i;
for(i=0; i<=3; i++)
{
char *p = xstrchr(b[i], a);
//printf("%s", b[i]);
printf("%s", p);
}
/*i=0;
while (b[3][i]!='\0')
{
if (a == b[3][i])
printf("\nThis is a test: %s",
b[i]);
i++;
}*/
}
char *xstrchr(char *string, char w)
{
//while(*string!='\0')
//{
// if (*string == w)
// {
// //printf("%s", string);
// return *string;
// break;
// }
// //printf("%s", string);
// string++;
//}
//char *s1 = string;
printf("%s", *string);
while(string != '\0')
{
printf("this is a test");
if(s == w)
{
printf("%c", s);
return (s1);
break;
}
*string++;
}
printf("\n");
return NULL;
}
Thanks
Pradyut
http://pradyut.tk
http://groups.yahoo.com/group/d_dom/
http://groups-beta.google.com/group/oop_programming
India