atoi问题() [英] Problem with atoi()

查看:83
本文介绍了atoi问题()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是:

我有:

char matrix [3] [3] = ....

int x;

x = atoi(矩阵[2] [2]);


这不行。有什么帮助吗?


我没有任何错误。只是一个警告传递参数1''atoi''

从整数中生成指针而没有强制转换

Hi,My problem is this:
I have :
char matrix[3][3]=....
int x;
x=atoi(matrix[2][2]);

This doesn''t work.Any help?

I don''t have any errors.Just a warning" passing argument 1 of ''atoi''
makes pointer from integer without a cast"

推荐答案

On Sun,2007年9月9日12:30:47 +0000,tolkien写道:
On Sun, 09 Sep 2007 12:30:47 +0000, tolkien wrote:

我的问题是:

我有:

char matrix [3] [3] = ....

int x;

x = atoi(matrix [2] [2 ]);


这不行。有什么帮助吗?
Hi,My problem is this:
I have :
char matrix[3][3]=....
int x;
x=atoi(matrix[2][2]);

This doesn''t work.Any help?



atoi获取指向char的指针。 matrix [2] [2]是一个char。

你想做什么?我很想说也许你的意思是

atoi(& matrix [2] [2])"但是矩阵[2] [2]是最后一个字节。
你定义的
对象,所以它不能是非空的

字符串的开头。


-

Army1987(将NOSPAM替换为电子邮件)

如果您要从Windows计算机发送电子邮件,请关闭Microsoft的

愚蠢的??智能行情?特征。这样你就可以避免通过你的邮件洒垃圾
字符了。 - Eric S. Raymond和Rick Moen

atoi takes a pointer to char. matrix[2][2] is a char.
What are you trying to do? I''d be tempted to say "maybe you mean
atoi(&matrix[2][2])", but matrix[2][2] is the last byte in the
object you defined, so it can''t be the beginning of a nonempty
string.

--
Army1987 (Replace "NOSPAM" with "email")
If you''re sending e-mail from a Windows machine, turn off Microsoft''s
stupid a??Smart Quotesa?? feature. This is so you''ll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen


tolkien写道:
tolkien wrote:

我的问题是:

我有:

char matrix [3] [3] = ....

int x;

x = atoi(矩阵[2] [2]);


这不行。有什么帮助吗?


我没有任何错误。只是一个警告传递参数1''atoi''

从整数中生成指针而没有强制转换
Hi,My problem is this:
I have :
char matrix[3][3]=....
int x;
x=atoi(matrix[2][2]);

This doesn''t work.Any help?

I don''t have any errors.Just a warning" passing argument 1 of ''atoi''
makes pointer from integer without a cast"



这里有一个线索。原型:


int atoi(con​​st char * _s);


注意矩阵[2] [2]是char类型,而不是char *。


-

Joe Wright

所有东西都应尽可能简单,但不能简单。 ;

---阿尔伯特爱因斯坦---

Here''s a clue. The prototype:

int atoi(const char *_s);

Note matrix[2][2] is type char, not char*.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---


我有这个矩阵:

char matrix [3] [3] = {''3'',''4'',''5'',

''6'',''7'',''8'',

''1'','''',''3''};


我希望将其中一个元素用作整数。

例如int x = matrix [1] [2](8)

i have this matrix:
char matrix[3][3]={''3'',''4'',''5'',
''6'',''7'',''8'',
''1'',''2'',''3'' };

and i want to use one of its elements as integer .
for example int x= matrix[1][2] (8)


这篇关于atoi问题()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆