这个简单的程序在OJ上为什么提示runtime error?
#include"stdio.h"#include"string.h"#include"stdlib.h"voidsearch(char*tobesearched){ch...
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
void search(char *tobesearched)
{
char * p = NULL;
char token[255] = { 0 };
char result[255] = { 0 };
p = strtok(tobesearched, " ");
while (p)
{
strcpy(token, p);
if (strchr(token, 'a') && strlen(token)>strlen(result))
strcpy(result, token);
p = strtok(NULL, " ");
}
if (strlen(result) == 0) printf("Not found\n");
else printf("%s\n", result);
}
int main()
{
char s[255] = { 0 };
gets(s);
search(s);
system("PAUSE");
return(1);
}
求解答呀 明天晚上就是作业截止了。。。!!
OJ系统显示的结果是Runtime error (exitcode: 1) 展开
#include "string.h"
#include "stdlib.h"
void search(char *tobesearched)
{
char * p = NULL;
char token[255] = { 0 };
char result[255] = { 0 };
p = strtok(tobesearched, " ");
while (p)
{
strcpy(token, p);
if (strchr(token, 'a') && strlen(token)>strlen(result))
strcpy(result, token);
p = strtok(NULL, " ");
}
if (strlen(result) == 0) printf("Not found\n");
else printf("%s\n", result);
}
int main()
{
char s[255] = { 0 };
gets(s);
search(s);
system("PAUSE");
return(1);
}
求解答呀 明天晚上就是作业截止了。。。!!
OJ系统显示的结果是Runtime error (exitcode: 1) 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询