大家好,我最近在學C語言時,編了下面這個程序,編譯能通過,運行時卻出現系統提示的錯誤信息!昏迷了…我用的編譯器是 Dev-C++ 4.9.8.0
上傳的圖片不知成功沒! ̄ ̄試試再說 ̄!!
#include”stdio.h”
#include”stdlib.h”
#define MAXLINE 1000
int getline (char line [], int max);
int strindex (char source [], char searchfor []);
char pattern [] = “ould”;
main ()
{
char line [MAXLINE];
int found = 0;
while (getline (line, MAXLINE) > 0)
{
if (strindex (line, pattern) >= 0)printf (“%S”, line);
}
system (“pause”);
}
int getline (char s[], int lim)
{
int c, i;
i = 0;
FILE *fp;
fp = fopen (“C:\\Documents and Settings\\Brooke.Li\\桌面\\fould.text”,”r“);
while (–lim > 0 && (c = getc (fp)) != EOF && c != ‘\n’)
s[i++] = c;
if (c == ‘\n’)
s[i++] = c;
s[i] = ‘\0′;
return i;
}
int strindex(char s[], char t[])
{
int i, j, k;
for (i = 0; s[i] != ‘\0′; i++)
{
for (j=i, k=0; t[k] != ‘\0′ && s[j] == t[k]; j++, k++)
{;}
if (k > 0 && t[k] == ‘\0′) return i;
}
return -1;
}
>> 本文固定链接: http://www.vcgood.com/archives/2194
163的圖片不公開呀。浪費表情!~~~
唉呀,誰幫看看這問題呀。太迷惑了~~~