具有二维数组的链接列表 [英] Linked list with bidimensional array

查看:95
本文介绍了具有二维数组的链接列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!我的程序有问题。


我创建了这个结构:


typedef struct tabela tabela;

struct tabela {

char nome [50];

int nColunas;

int nLinhas;

char nomeColunas [10] [50];

char valores [50] [65];

tabela * next;

} ;

我的问题如下:


我可以成功改变nome [50],nColunas和nLinhas的价值,

但我似乎无法将字符串插入nomeColunas或

valores。


这是模拟SQL表,nomeColunas [ 10] [50]表示

你可以拥有10个不同的collum名称和50字节的名字长度。


Valores [50] [65]表示你可以拥有50行价值,其名称长度为
50字节。


我的问题是,如何创建一个允许我改变的函数

这两个bidimensio的值nal数组?


提前感谢您的帮助。

解决方案

Pedro Pinto写道:


你好!我的程序有问题。


我创建了这个结构:


typedef struct tabela tabela;

struct tabela {

char nome [50];

int nColunas;

int nLinhas;

char nomeColunas [10] [50];

char valores [50] [65];

tabela * next;

} ;


我的问题如下:


我可以成功地改变nome [50],nColunas和nLinhas的值,

但我似乎无法将字符串插入nomeColunas或

valores。



为什么不呢?


我的意思是,你做什么,会发生什么?

我假设你已经在常见问题解答中看到了相关的内容,

并且你有一本体面的C书,而且你已经/>
读取其相关部分,因此你知道C字符串是什么和

C'的多维数组是什么真的是。


-

克里斯unhashedup哈希哈希 Dollin

网络的路径越来越宽 - 十月项目


在< 11 ********************** @ h48g2000cwc .googlegroups .com" Pedro Pinto" < ku ***** @ gmail.comwrites:


typedef struct tabela tabela;

struct tabela {

char nome [50];

int nColunas;

int nLinhas;

char nomeColunas [10] [50];

char valores [50] [65];

tabela * next;

};


我可以成功改变nome [50],nColunas和nLinhas的价值,

但是我不能似乎能够将字符串插入nomeColunas或

valores。



你应该可以,例如:


strcpy(myTabela.nomeColunas [4],你好! ");

strcpy(myTabela.valores [4],Goodbye!);


发布你的代码,我们会试着帮助你弄清楚出了什么问题。


-

John Gordon它肯定没有被奶酪污染。
go_S@panix.com


Pedro Pinto写道:


你好!我的程序有问题。


我创建了这个结构:


typedef struct tabela tabela;

struct tabela {

char nome [50];

int nColunas;

int nLinhas;

char nomeColunas [10] [50];

char valores [50] [65];

tabela * next;

} ;


我的问题如下:


我可以成功地改变nome [50],nColunas和nLinhas的值,

但我似乎无法将字符串插入nomeColunas或

valores。


这是模拟SQL table,nomeColunas [10] [50]表示

你可以拥有10个不同的collum名称和50个字节的名字长度。


Valores [50] [ 65]表示您可以拥有50行值,其名称长度为
50字节。



65字节长度


>

我的问题是,我如何创建一个允许我改变这两个二维数组值的函数?


提前感谢您的帮助。



这个小例子怎么样


#include< stdio.h>

#include< string .h>


typedef struct tabela tabela;

struct tabela {

char nome [50];

int nColunas;

int nLinhas;

char nomeColunas [10] [50];

char valores [50] [65] ;

struct tabela * next;

};


int main(int argc,char * argv [])

{

tabela x;

tabela * x_ptr;


x_ptr =& x;


strcpy(x_ptr-> nome," testname");

strcpy(x_ptr-> nomeColunas [0]," testcol1");

strcpy(x_ptr-> nome Colunas [1],testcol2);


printf("%s \ n",x.nome);

printf(" ;%s \ n",x.nomeColunas [0]);

printf("%s \ n",x.nomeColunas [1]);

返回0;

}


-


Adrian


Hi there! I''m having a problem in my program.

i''ve created this structure:

typedef struct tabela tabela;
struct tabela {
char nome[50];
int nColunas;
int nLinhas;
char nomeColunas[10][50];
char valores[50][65];
tabela *next;
};
my problem is the following:

I can sucessfully alter the values of nome[50], nColunas and nLinhas,
but i can''t seem to be able to insert a string into nomeColunas or
valores.

This is to simulate an SQL table, nomeColunas[10][50] indicates that
you can have 10 diferent collum names with a 50 bytes name length.

Valores[50][65] indicates that you can have 50 lines of values with a
50 bytes name length.

My question is, how can i create a function that permits me to alter
the value on these two bidimensional arrays?

Thanks in advance for any help.

解决方案

Pedro Pinto wrote:

Hi there! I''m having a problem in my program.

i''ve created this structure:

typedef struct tabela tabela;
struct tabela {
char nome[50];
int nColunas;
int nLinhas;
char nomeColunas[10][50];
char valores[50][65];
tabela *next;
};
my problem is the following:

I can sucessfully alter the values of nome[50], nColunas and nLinhas,
but i can''t seem to be able to insert a string into nomeColunas or
valores.

Why not?

I mean, what do you do, and what happens?

I assume you''ve read anything in the FAQ that looked relevant,
and that you''ve got a decent C book to hand, and that you''ve
read its relevant sections, so you know what a C string is and
what C''s "multi-dimensional arrays" really are.

--
Chris "unhashedup hashed up hashing" Dollin
"The path to the web becomes deeper and wider" - October Project


In <11**********************@h48g2000cwc.googlegroups .com"Pedro Pinto" <ku*****@gmail.comwrites:

typedef struct tabela tabela;
struct tabela {
char nome[50];
int nColunas;
int nLinhas;
char nomeColunas[10][50];
char valores[50][65];
tabela *next;
};

I can sucessfully alter the values of nome[50], nColunas and nLinhas,
but i can''t seem to be able to insert a string into nomeColunas or
valores.

You should be able to, for example:

strcpy(myTabela.nomeColunas[4], "Hello!");
strcpy(myTabela.valores[4], "Goodbye!");

Post your code, and we''ll try to help you figure out what''s wrong.

--
John Gordon "It''s certainly uncontaminated by cheese."
go****@panix.com


Pedro Pinto wrote:

Hi there! I''m having a problem in my program.

i''ve created this structure:

typedef struct tabela tabela;
struct tabela {
char nome[50];
int nColunas;
int nLinhas;
char nomeColunas[10][50];
char valores[50][65];
tabela *next;
};
my problem is the following:

I can sucessfully alter the values of nome[50], nColunas and nLinhas,
but i can''t seem to be able to insert a string into nomeColunas or
valores.

This is to simulate an SQL table, nomeColunas[10][50] indicates that
you can have 10 diferent collum names with a 50 bytes name length.

Valores[50][65] indicates that you can have 50 lines of values with a
50 bytes name length.

65 bytes in length

>
My question is, how can i create a function that permits me to alter
the value on these two bidimensional arrays?

Thanks in advance for any help.

How about this small example

#include <stdio.h>
#include <string.h>

typedef struct tabela tabela;
struct tabela {
char nome[50];
int nColunas;
int nLinhas;
char nomeColunas[10][50];
char valores[50][65];
struct tabela *next;
};

int main(int argc, char *argv[])
{
tabela x;
tabela *x_ptr;

x_ptr=&x;

strcpy(x_ptr->nome, "testname");
strcpy(x_ptr->nomeColunas[0], "testcol1");
strcpy(x_ptr->nomeColunas[1], "testcol2");

printf("%s\n", x.nome);
printf("%s\n", x.nomeColunas[0]);
printf("%s\n", x.nomeColunas[1]);

return 0;
}

--

Adrian


这篇关于具有二维数组的链接列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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