srik545
BAN USER-------------------------------------------------
char* strstr1(char* str, char* substr)
{
char* tmpstr = str;
char* tmpsubstr = substr;
char* resultstr=NULL;
bool inmatch = false;
while((*tmpstr!= '\0')) {
if(*tmpstr == *tmpsubstr) {
resultstr = tmpstr;
inmatch = true;
do {
if(*tmpstr != *tmpsubstr) {
inmatch = false;
break;
}
tmpstr++;
tmpsubstr++;
} while(*tmpstr!= '\0' && *tmpsubstr != '\0' );
if((*tmpsubstr == '\0') && (inmatch == true)) {
return resultstr;
} else {
tmpsubstr = substr;
resultstr = NULL;
continue;
}
}
tmpstr++;
}
return resultstr;
}
-------------------------------------------------
-------------------------------------------------
char* strstr1(char* str, char* substr)
{
char* tmpstr = str;
char* tmpsubstr = substr;
char* resultstr=NULL;
bool inmatch = false;
while((*tmpstr!= '\0')) {
if(*tmpstr == *tmpsubstr) {
resultstr = tmpstr;
inmatch = true;
do {
if(*tmpstr != *tmpsubstr) {
inmatch = false;
break;
}
tmpstr++;
tmpsubstr++;
} while(*tmpstr!= '\0' && *tmpsubstr != '\0' );
if((*tmpsubstr == '\0') && (inmatch == true)) {
return resultstr;
} else {
tmpsubstr = substr;
resultstr = NULL;
continue;
}
}
tmpstr++;
}
return resultstr;
}
-------------------------------------------------
-------------------------------------------------
char* strstr1(char* str, char* substr)
{
char* tmpstr = str;
char* tmpsubstr = substr;
char* resultstr=NULL;
bool inmatch = false;
while((*tmpstr!= '\0')) {
if(*tmpstr == *tmpsubstr) {
resultstr = tmpstr;
inmatch = true;
do {
if(*tmpstr != *tmpsubstr) {
inmatch = false;
break;
}
tmpstr++;
tmpsubstr++;
} while(*tmpstr!= '\0' && *tmpsubstr != '\0' );
if((*tmpsubstr == '\0') && (inmatch == true)) {
return resultstr;
} else {
tmpsubstr = substr;
resultstr = NULL;
continue;
}
}
tmpstr++;
}
return resultstr;
}
-------------------------------------------------
-------------------------------------------------
char* strstr1(char* str, char* substr)
{
char* tmpstr = str;
char* tmpsubstr = substr;
char* resultstr=NULL;
bool inmatch = false;
while((*tmpstr!= '\0')) {
if(*tmpstr == *tmpsubstr) {
resultstr = tmpstr;
inmatch = true;
do {
if(*tmpstr != *tmpsubstr) {
inmatch = false;
break;
}
tmpstr++;
tmpsubstr++;
} while(*tmpstr!= '\0' && *tmpsubstr != '\0' );
if((*tmpsubstr == '\0') && (inmatch == true)) {
return resultstr;
} else {
tmpsubstr = substr;
resultstr = NULL;
continue;
}
}
tmpstr++;
}
return resultstr;
}
-------------------------------------------------
Here is what I came up with strstr(). Hope this helps to others:
char* strstr1(char* str, char* substr)
{
char* tmpstr = str;
char* tmpsubstr = substr;
char* resultstr=NULL;
bool inmatch = false;
while((*tmpstr!= '\0')) {
if(*tmpstr == *tmpsubstr) {
resultstr = tmpstr;
inmatch = true;
do {
if(*tmpstr != *tmpsubstr) {
inmatch = false;
break;
}
tmpstr++;
tmpsubstr++;
} while(*tmpstr!= '\0' && *tmpsubstr != '\0' );
if((*tmpsubstr == '\0') && (inmatch == true)) {
return resultstr;
} else {
tmpsubstr = substr;
resultstr = NULL;
continue;
}
}
tmpstr++;
}
return resultstr;
}
Here is what I came up with strstr(). Hope this helps to others:
char* strstr1(char* str, char* substr)
{
char* tmpstr = str;
char* tmpsubstr = substr;
char* resultstr=NULL;
bool inmatch = false;
while((*tmpstr!= '\0')) {
if(*tmpstr == *tmpsubstr) {
resultstr = tmpstr;
inmatch = true;
do {
if(*tmpstr != *tmpsubstr) {
inmatch = false;
break;
}
tmpstr++;
tmpsubstr++;
} while(*tmpstr!= '\0' && *tmpsubstr != '\0' );
if((*tmpsubstr == '\0') && (inmatch == true)) {
return resultstr;
} else {
tmpsubstr = substr;
resultstr = NULL;
continue;
}
}
tmpstr++;
}
return resultstr;
}
It is stack because even the process execution uses stack to execute the functions which are present in the program. For example, while debugging the process using gdb, few commands are stack trace... .
- srik545 March 28, 2013