公网ip+内网穿透+c_str()+linux c++读文件+路径

通常家里的ip在国内百分之九十九是内网的ip的。通常只有服务器才会是这个公网的ip,因为公网的ip,内网的电脑可以访问,反过来是不可以的。公网ip是唯一的,但是内网地址你家是192.168..1.23,那么邻居家也可以是的。内网地址的访问是:A类:10.0.0.0~10.255.255.255,B类:172.16.0.0,~172.31.255.255,C类:192.168.0.0.~192.168.255.255.

最简单的直接上canyouseeme.org,查一下自己映射的端口……显示成功就是公网ip

 

ssh适用在局域网(可以理解成一个路由器下的电脑)或者有公网ip的电脑(公网ip是全世界唯一的ip) 或者使用其他技术进行破解 (内网穿透)

 

打电话10010,转人工客服,在家办公需要就可申请公网ip

内网穿透(以下步骤配合www.nat123.com/pages_17_600.jsp)

1. wget http://www.nat123.com/down/nat123linux.tar.gz
2. tar -zxvf nat123linux.tar.gz
3. bash nat123linux.sh
4. chmod 777 nat123linux.sh
5. bash nat123linux.sh service &
6. ./nat123linux.sh
7. 注册http://www.nat123.com/UsersReg.jsp
8. 设置端口映射添加 内网22端口 (记住域名和外端口 putty登陆需要)
9. #bash nat123linux.sh 
10. 安装nat123_V1.200505.exe
11. 防火墙白名单 添加访问者ip
12. 
vim /etc/ssh/sshd_config
将
PasswordAuthentication no
更改为
PasswordAuthentication yes
按【ESC】输入保存:
:wq
再输入命令重启服务
service sshd restart
13. sudo /etc/init.d/ssh restart
14. 访问者使用putty登陆

语法: const char *c_str();c_str()函数返回一个指向正bai规C字符串的指针, 内容与du本string串相同. 这是为了与c语言兼容,在zhic语言中没有daostring类型,故必须通过string类对象的成员函数c_str()把string 对象转换成c中的字符串样式。注意:一定要使用strcpy()函数 等来操作方法c_str()返回的指针 比如:最好不要这样: char* c; string s="1234"; c = s.c_str(); //c最后指向的内容是垃圾,因为s对象被析构,其内容被处理应该这样用: char c[20]; string s="1234"; strcpy(c,s.c_str()); 这样才不会出错,c_str()返回的是一个临时指针,不能对其进行操作

再举个例子c_str() 以 char* 形式传回 string 内含字符串如果一个函数要求char*参数,可以使用c_str()方法: string s = "Hello World!";printf("%s", s.c_str()); //输出 "Hello World!"

 

 

dir('.')列出当前目录下所有子文件夹和文件
dir('G:\Matlab')列出指定目录下所有子文件夹和文件
dir('*.m')列出当前目录下符合正则表达式的文件夹和文件

读取F:\File下所有txt文件:
namelist = dir('F:\File\*.txt');

% 读取后namelist 的格式为
% name -- filename
% date -- modification date
% bytes -- number of bytes allocated to the file
% isdir -- 1 if name is a directory and 0 if not

len = length(namelist);
for i = 1:len
    file_name{i}=namelist(i).name;
    x= load(file_name{i});
end

 

修改路径
 

string sDirectory ;
chdir(sDirectory.c_str());

注意chdir需要一个 const char * ,而不是 std :: string ,因此必须使用 .c_str()。

 

 

linux获取当前路径

#include <stdio.h>
#include <unistd.h>
char *buffer;
buffer = getcwd(NULL, 0);
cout << "文件路径" << buffer << endl;//将需要调用的模块使用 strcat 作拼接;
const char *model_path = strcat(buffer,"/models");

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值