ChinaUnix.net
相关文章推荐:

指针数组赋值

代码: #include "iostream.h" #include "stdio.h" #include "string.h" #include "ctype.h" struct ylj {char *ys[8]; struct ylj *next; }; void main() {struct ylj *p1; p1=new ylj; char ch='a'; (*(p1->;ys[1])+1)=ch; cout<<"中文"<

by hbszrbw - C/C++ - 2003-11-27 22:54:54 阅读(1775) 回复(0)

相关讨论

int num; int i,s; char *name[]={"111.111.111.111","111.111.111.111","111.111.111.111","111.111.111.111","111.111.111.111","111.111.111.111"}; s = socket(PF_INET, SOCK_DGRAM, 0); conf.ifc_len = BUFSIZ; conf.ifc_buf = buff; ioctl(s, SIOCGIFCONF, &conf); num = conf.ifc_len / sizeof(struct ifreq); ifr = conf.ifc_req; for...

by qscf_520 - C/C++ - 2012-06-21 17:28:02 阅读(1161) 回复(0)

C语言中二维指针怎么赋值啊? char a[2][10] = {"i","am" "is"}; char **p = a+1; 想获取a数组从1开始的字符串,这么写报错了,test.cpp:27: 错误:cannot convert `char (*)[10]' to `char**' in initialization 怎么改啊?

by liumilan2009 - C/C++ - 2014-01-20 15:13:58 阅读(4208) 回复(4)

# include ; main() { char *a[3]; char b[5]; strcpy(b,"000"); a[0]=b; strcpy(b,"111"); a[1]=b; printf("a0=%s,a1=%s",a[0],a[1]); } 为什么输出全是111,是不是把a的所有元素全部赋111了? 请问,我的b是变化的,如何才能让上面的程序输出 a0=000,a1=111 呢?不知我说没说明白,就是想问如何将一个字符数组的内容,放到一个指针数组中的一个元素,且不...

by wellcome - C/C++ - 2004-12-05 13:06:36 阅读(6771) 回复(9)

俺需要如下内容是动态生成的,游牧有办法? int (*FunList[ 2 ])() = { Fun0, Fun1 } ; 即,这个数组的项 Fun0,Fun1 是动态生成的,或者是动态赋值的。 比如,根据不同的条件, FunList[0] = Fun0 , FunList[1]=Func3 .... 不知道俺说清楚木有? 晕了。

by snow888 - C/C++ - 2011-12-01 17:53:55 阅读(10827) 回复(31)

[ 本帖最后由 xiaowh00 于 2012-08-10 17:01 编辑 ] #include #include #include #define MAX 5 #define LEN 100 // Write a program that reads in up to 10 strings or to EOF, whichever comes first. Have it offer the user a menu with five choices: print the original list of strings, print the strings in ASCII collating sequence, print the strings in order of increasing len...

by xiaowh00 - C/C++ - 2012-08-13 09:02:19 阅读(2234) 回复(7)

俺需要如下内容是动态生成的,游牧有办法? int (*FunList[ 2 ])() = { Fun0, Fun1 } ; 即,这个数组的项 Fun0,Fun1 是动态生成的,或者是动态赋值的。 比如,根据不同的条件, FunList[0] = Fun0 , FunList[1]=Func3 .... 不知道俺说清楚木有? 晕了。 PS: 这个 Fun0 ,Fun1 ... 是根据不同的条件从数据库中取出来的,也许取出的内容是 Fun1,Fun3 ,这个取出的咚咚是字符串数组。

by snow888 - Linux环境编程 - 2011-11-27 02:36:58 阅读(2202) 回复(5)

#include #define N 2 struct stu{ char *num; char *name; int score[3]; }students[N]; void main() { int i,j; for (i=0;i

by wsswh - C/C++ - 2011-11-23 09:44:14 阅读(2402) 回复(3)

下面这个代码里报错说“Line 16 incompatible types in assignment”,我不知为什么会出这种问题,请各位指点,谢谢! /* Two D array pointer assignment from string-returning functions*/ #include #define NAM 2 #define LEN 21 char * retinput(void); int main(void){ char names[NAM][LEN]; int i; for(i = 0; i < NAM; i++){ names = retinput(); /*报错说这里的赋值类型不...

by mcmay - C/C++ - 2008-11-11 23:40:33 阅读(5741) 回复(5)

#include #include #include #include using namespace std; [code] int main() { int *p[10]; int *pp[10]; for(int i = 0; i < 10; i++) p = new int(i); for(int i = 0; i < 10; i++) printf("p=%d\n", *p); pp = p; //error pp = &p; //error pp = &p[0]; //error //有什么直接办法把p中的元素让pp能使用,难道只能逐个元素复制吗? int *q; int...

by brookqiao - C/C++ - 2008-01-23 11:39:36 阅读(7132) 回复(2)

#include int main(int argc, char *argv[]){ while(1){ int (*p)[2]; *p = 1; return 1; } } 定义一个数组指针, 将数组的第一个元素赋值为1,为什么编译出错,我是一名初学者. 错误:赋值时类型不兼容

by yangbo8481 - C/C++ - 2006-07-12 21:43:23 阅读(2781) 回复(11)