両方とも同じである 2 つの char 文字列を比較する際に問題が発生しています。
char string[50];
strncpy(string, "StringToCompare", 49);
if( !strcmp("StringToCompare", string) )
//do stuff
else
//the code runs into here even tho both strings are the same...this is what the problem is.
私が使用する場合:
strcpy(string, "StringToCompare");
それ以外の:
strncpy(string, "StringToCompare", 49);
問題は解決しますが、文字列自体を取得するのではなく、文字列の長さを挿入したいと思います。
ここで何がうまくいかないのですか?この問題を解決するにはどうすればよいですか?