Windows下将c的char指针数组转换为c指针的问题 [英] problem in casting the char pointer array to char pointer in c under windows

查看:189
本文介绍了Windows下将c的char指针数组转换为c指针的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我创建了指针数组:

char * p [10];
p [1] ="hai";
p [2] ="how";


我想隐瞒char *;

我使用类型转换

char * a =(char *)p;


正确吗?

我该如何抛弃它.

sir i created the pointer array:

char *p[10];
p[1]="hai";
p[2]="how";


i want to covert to the char*;

i use typecasting

char *a = (char*)p;


Is it correct..

how can i decast that . and how to get the data back..

推荐答案

char *p[10];
char *a = (char*)p;

不正确(这就是您需要添加演员表的原因)

char* p[10]创建一个包含十个字符指针的数组,char *a创建一个字符指针.
为了将p 的值加载到a中,它必须是char**:

Is not right (that''s why you needed to add the cast)

char* p[10] creates an array of ten character pointers, char *a creates a character pointer.
In order to load the value of p into a, it needs to be a char**:

char *p[10];
char **a = p;


这篇关于Windows下将c的char指针数组转换为c指针的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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