以下が僕の作ってみたプログラムです。
#include <stdio.h>
int equal(char a[],char b[])
{
int i;
while(a[i]!=0)
{
if(a[i]!=b[i])
{
return(0);
}
i=i+1;
}
return(1);
}
int main (void)
{
int answer;
answer=equal("hello","ohayou");
if(answer==1){
printf("correct\n");
}
else{
printf("miss\n");
}
return(0);
}
「
Debug Error!
Program: ...cumens\visual studio
2010\Projects\ex4-3.c\Debug\ex4-3.c.exe
Module: ...cuments\cisual studio
2010\Projects\ex4-3.c\Debug\ex4-3.c.exe
File:
Run - Time Checked Failure #3 - The variable 'i' is being used without being initialized.
(Press Retry to debug the application)
」
とでてきてしまいます。
このプログラムに何かおかしいところがあるということでしょうか?
おかしなところがあれば教えていただきたいです。
現在の環境は以下のとおりです
OS:Windows 7 Home Premium
コンパイラ:Microsoft Visual C++ 2010 Express
よろしくお願いします。