我需要逐行搜索文件中的两个特定单词,如果它们存在,则打印“Found!”。 这FILE.TXT(有四列) bill gates 62bill microsoft
beyonce knowles 300mill entertainment
my name -$9000 student
以下是我提出的想法,但似乎并没有工作 char firstname[];
char lastname[];
条件 可能重复:“是的,它的工作原理” How do I properly compare strings in C? #include <iostream>
using namespace std;
int main(){
char name[100];
cout<<"Enter: ";
cin>>name;
if(name == "hello")
我遇到比较2个字符字符串都是同样的问题时: 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 sam
我的问题是,STRCMP()函数提出了以下问题: main.c:35: warning: passing argument 1 of ‘strcmp’ makes pointer from integer without a cast
虽然编译和以下运行程序时: Segmentation fault: 11
我知道错误是什么意思,我只是不知道任何其他方式来做到这一点...有没有想过使用it