C++ 为什么在我包含正确的C++;图书馆?
当我包含所需的库时,“#include..”行不会显示任何警告。但当我使用该库中的函数时,我发现Vim显示“.未声明函数的使用…”。图书馆似乎没有被正确收录。所以我想知道如何解决这个问题 此问题的截图随附如下:C++ 为什么在我包含正确的C++;图书馆?,c++,vim,youcompleteme,C++,Vim,Youcompleteme,当我包含所需的库时,“#include..”行不会显示任何警告。但当我使用该库中的函数时,我发现Vim显示“.未声明函数的使用…”。图书馆似乎没有被正确收录。所以我想知道如何解决这个问题 此问题的截图随附如下: 尝试将其包括在以下内容中: #include <stdlib.h> //use <> instead of "" 是的 printf("s"); 现在,如果你真的想打印一个字符“s”,那么使用 printf("%c", 's'); // Tells
尝试将其包括在以下内容中:
#include <stdlib.h> //use <> instead of ""
是的
printf("s");
现在,如果你真的想打印一个字符“s”,那么使用
printf("%c", 's'); // Tells the printf function that 's' is a character
最终的代码如下所示
#include <stdio.h>
int main(int argc, char** argv) {
printf("s");
printf("%c", 's');
return 0;
}
#包括
int main(int argc,字符**argv){
printf(“s”);
printf(“%c”,s”);
返回0;
}
现在,你的评论是“cout”不起作用。为了让“cout”发挥作用,您需要包括iostream库:
#include <iostream>
#包括
然后,您可以在代码中使用“cout”
std::cout << 's';
std::cout << "s";
std::难道它还是不起作用。实际上,当我包含iostream并使用namespace std时,“…cout…”行也不起作用。因此,我认为这不是因为这个原因。我编辑(更新)了答案,并逐步解决了您的问题。
#include <stdio.h>
int main(int argc, char** argv) {
printf("s");
printf("%c", 's');
return 0;
}
#include <iostream>
std::cout << 's';
std::cout << "s";
include <iostream>
using namespace std;
cout << 's';
cout << "s";
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
cout << 's';
cout << "s";
return 0;
}