与字符串> INT [英] string->int
问题描述
你好
我从存储在每一行的文件编号中提取。
这是我知道提取每个文件的唯一方法一次从文件中划线
,使用< fstream> < ostream的> :
char缓冲区[32];
ifstream LZW(sz_path);
而(!LZW.eof())
{
memset(缓冲区,0,sizeof(缓冲区));
LZW .getline(buffer,sizeof(buffer)-1);
}
//缓冲区保存例如:" 123"我想将它转换为int x =
123以便我以后可以使用它,例如my_array [123] =
......
任何人都可以在这方面提供帮助。
谢谢你,
alex
hello
i''m extracting from a file numbers that are stored on each line.
this is the only way i know to extract each line at a time from a file
, using <fstream> <ostream> :
char buffer[32];
ifstream LZW(sz_path);
while(!LZW.eof())
{
memset(buffer, 0, sizeof(buffer));
LZW.getline(buffer, sizeof(buffer)-1);
}
// buffer holds for example : "123" and i want to convert it to int x =
123 so that i can work with it later , like for example my_array[123] =
......
can anybody provide help in this aspect.
thank you,
alex
推荐答案
" grubbymaster" < GR ********** @ gmail.com>在留言中写道
news:11 ********************** @ u72g2000cwu.googlegr oups.com ...
"grubbymaster" <gr**********@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
你好
我从每行存储的文件号中提取。
这是我知道从文件中一次提取每一行的唯一方法。
,使用< fstream> < ostream的> :
char buffer [32];
ifstream LZW(sz_path);
while(!LZW.eof())
{
memset(buffer,0,sizeof(buffer));
LZW.getline(buffer,sizeof(buffer)-1);
}
//缓冲区保存例如:123并且我想将它转换为int x =
123以便我以后可以使用它,例如my_array [123] =
.....
可以任何人都提供这方面的帮助。
谢谢你,
alex
hello
i''m extracting from a file numbers that are stored on each line.
this is the only way i know to extract each line at a time from a file
, using <fstream> <ostream> :
char buffer[32];
ifstream LZW(sz_path);
while(!LZW.eof())
{
memset(buffer, 0, sizeof(buffer));
LZW.getline(buffer, sizeof(buffer)-1);
}
// buffer holds for example : "123" and i want to convert it to int x =
123 so that i can work with it later , like for example my_array[123] =
.....
can anybody provide help in this aspect.
thank you,
alex
看看sscanf()
Allan
have a look at sscanf()
Allan
grubbymaster写道:
grubbymaster wrote:
你好
这是我知道从文件中一次提取每一行的唯一方法
,使用< fstream> < ostream的> :
fstream和ostream不是C.
//缓冲区保持例如:123我想将它转换为int x =
123以便我以后可以使用它,例如my_array [123] =
hello
i''m extracting from a file numbers that are stored on each line.
this is the only way i know to extract each line at a time from a file
, using <fstream> <ostream> :
fstream and ostream are not C.
// buffer holds for example : "123" and i want to convert it to int x =
123 so that i can work with it later , like for example my_array[123] =
如果我正确理解你想要的东西,atoi()就是你在寻找
for。
If I understand correctly what you want , atoi() is what you''re looking
for.
我发布了上述消息在comp.lang.c;我不知道
它是如何结束的。
Spiros Bousbouras
I posted the above message on comp.lang.c ; I have no idea
how it ended up here as well.
Spiros Bousbouras
这篇关于与字符串> INT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!