windows 上用云主机运行C++程序

使用的是金山云主机。

SSH连接Linux云主机 的说明:(需要下载Putty)

https://docs.ksyun.com/read/latest/129/_book/connectdamibyssh.html

在putty的host name中输入你的公网IP,点击open。
登陆用户名,和密码。输入密码,看不见输入不要慌,linux就是这样保护安全的。
登陆成功之后就进入了与主机的ubuntu系统。


把文件传到云主机:

使用FileZilla进行文件传输,很简单,下载安装启动,一看就会的。

配置环境及运行实例:

$ sudo apt-get install build-essential
# waiting...
$ mkdir cpp
$ cd cpp
$ vim test.cpp
//~ edit test.cpp with vim or other editor like the upcoming lines.
#include <iostream>
using namespace std;
int
main()
{
cout<<"hello, world"<<endl;
return 0;
}

$ g++ test.cpp -o test
$ ls
test.cpp test
$ ./test
$ hello, world

注意:

abs()和fabs()函数的区别;

abs( )主要用于对求整数的绝对值,在“stdlib.h”(或 <cstdlib>)头文件里面。

fabs( )主要是求精度要求更高的double ,float 型的绝对值,在<cmath>头文件里。

两者在只#include<cmath>时都可以使用。


system("PAUSE"); 要去掉.
sprintf_s()要改为sprintf().



猜你喜欢

转载自blog.csdn.net/hanshuning/article/details/79090308