新的C++ 11是否包含任何套接字库?那么一个人可以做点什么 - 什么std::socket?
看看std::thread将如何添加,感觉好像应该添加套接字.C风格的插座很痛苦...他们觉得非常反直觉.
无论如何:C++ 11中是否会有C++套接字(用Google搜索但无法找到答案)?如果没有,他们是否计划添加此项?为什么(/为什么不呢?)
我刚刚发现了ncurses并且刚刚开始学习它,但是我的教程中的示例不能在我的计算机上编译.
我必须手动安装ncurses,并输入"apt-get install libncurses5-dev libncursesw5-dev".我不得不这样做,因为在这样做之前我得到一个错误,说我不能"#include".
安装它工作,但现在我得到此错误:
touzen@comp:~/learning_ncurses$ g++ -o hello_world hello_world.cpp
/tmp/ccubZbvK.o: In function `main':
hello_world.cpp:(.text+0xa): undefined reference to `initscr'
hello_world.cpp:(.text+0x16): undefined reference to `printw'
hello_world.cpp:(.text+0x1b): undefined reference to `refresh'
hello_world.cpp:(.text+0x20): undefined reference to `stdscr'
hello_world.cpp:(.text+0x28): undefined reference to `wgetch'
hello_world.cpp:(.text+0x2d): undefined reference to `endwin'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我编译的代码如下所示:
#include <ncurses.h>
int main(){
initscr();
printw("Hai thar world...");
refresh();
getch();
endwin();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么我会收到此错误.更重要的是,我该如何解决这个问题呢?
我正在使用"使用C++编程原理和练习"一书来学习编程,其中一个练习是使用while循环遍历字符az.
现在,我之前用C++和其他语言编程,所以我决定尝试使用尽可能少的行(同时仍然使用while循环).然而,这与我的输出成本有点混乱.
码:
#include <iostream>
int main(){
char ch = 'a';
while(ch <= 'z')
std::cout << ch << '\t' << (int) ch++ << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
b 97
c 98
d 99
e 100
...
x 119
y 120
z 121
{ 122
Run Code Online (Sandbox Code Playgroud)
现在我意识到这可以用for-loop完成,而且我也做了(它工作).但我仍然不知道这段代码有什么问题,这真让我烦恼.
看起来好像我告诉它输出"ch + 1",因为它打印出'b',它应该打印'a'.直到将ch的整数值放入流出后(后递增)之后才进行递增.即使我之前增加了它,至少打印的字符及其整数值应该对应.
有什么想法为什么这个代码不起作用?
我已经开始编程C++,我想开始编写有用的东西.
我知道对于字符串,可以使用std::string或char--arrays.也可以使用std::vectors,而不是数组.
应该怎么做?重新发明轮子,还是使用内置的实用程序?
问题的关键是找出人们实际做了什么.人们经常使用STL还是人们使用char[]而不是std::string?