1.strtok()函数
函数原型
char *strtok(char s[], const char *delim);
当strtok()在参数s的字符串中发现参数delim中包含的分割字符时,则会将该字符改为\0 字符。在第一次调用时,strtok()必需给予参数s字符串,往后的调用则将参数s设置成NULL。每次调用成功则返回指向被分割出片段的指针。
strtok函数会破坏被分解字符串的完整,调用前和调用后的s已经不一样了。
void readTxt()
{
char readLine[1000];
const char *delim=" ";
char *p;
for(int i=0; i<956; i++)
{
cin.getline(readLine,1000);
p=strtok(readLine,delim);
while(p)
{
gridTopo[i].push_back(atoi(p));
p = strtok(NULL, delim);
}
}
for(int i=0; i<4001; i++)
{
cin.getline(readLine,1000);
p=strtok(readLine,delim);
while(p)
{
request[i].push_back(atoi(p));
p = strtok(NULL, delim);
}
}
}
2.VS2013代码自动对齐
Ctrl+K 然后 Ctrl + F