C++
梦空11
大学生一枚
展开
-
C++ 读入写出txt
ifstream file(“e.txt”);ofstream mycout(“0604.txt”);while (!file.eof()){char txt_cont[200], * p;const char* d = “_”;//txt_cont 是读取数据file.getline(txt_cont, 200);//分割(取下划线前部分)p = strtok(txt_cont...原创 2019-11-26 21:49:13 · 196 阅读 · 0 评论 -
C语言中string char int类型转换
转载于:C语言中string char int类型转换1,char型数字转换为int型char a[] = "32";printf("%d\n", a[0]-'0');//输出结果为32,int转化为char*********************************** linux c ***********************************(1)字符串转换成数字,用atoi,atol,atof,分别对应的是整型,long型,double型。以整型为例:char st转载 2020-09-26 13:21:26 · 1284 阅读 · 0 评论 -
stringstream常见用法,string字符串的分割(c++)
string字符串的分割:stringstream的常见用法以stringstream数据流保存数据,然后用getline()间隔读取string类数据,达到分割string字符串的目的,并利用str.data()或者str.c_str()以及atoi()转化为int。#include <sstream>#include <string>#include <iostream>#include <cstdio>#include <vector原创 2020-09-25 22:55:39 · 3660 阅读 · 0 评论