相关讨论
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...
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
怎么改啊?
# 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
呢?不知我说没说明白,就是想问如何将一个字符数组的内容,放到一个指针数组中的一个元素,且不...
俺需要如下内容是动态生成的,游牧有办法?
int (*FunList[ 2 ])() = { Fun0, Fun1 } ;
即,这个数组的项 Fun0,Fun1 是动态生成的,或者是动态赋值的。
比如,根据不同的条件, FunList[0] = Fun0 , FunList[1]=Func3 ....
不知道俺说清楚木有?
晕了。
[ 本帖最后由 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...
俺需要如下内容是动态生成的,游牧有办法?
int (*FunList[ 2 ])() = { Fun0, Fun1 } ;
即,这个数组的项 Fun0,Fun1 是动态生成的,或者是动态赋值的。
比如,根据不同的条件, FunList[0] = Fun0 , FunList[1]=Func3 ....
不知道俺说清楚木有?
晕了。
PS:
这个 Fun0 ,Fun1 ... 是根据不同的条件从数据库中取出来的,也许取出的内容是 Fun1,Fun3 ,这个取出的咚咚是字符串数组。
#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...
#include
int main(int argc, char *argv[]){
while(1){
int (*p)[2];
*p = 1;
return 1;
}
}
定义一个数组指针, 将数组的第一个元素赋值为1,为什么编译出错,我是一名初学者.
错误:赋值时类型不兼容