[英]how to increase the size of 2d char array element size in c
char symbol[100][100];
for(i=0;i<n;i++)
{
printf("enter the symbol\n");
scanf("%s",&symbol[0][i]);
}
strncat(&symbol[0][0],"1",1);
output for ex:- in symbol[0][0] i have entered 'a' ex的输出 :-在符号[0] [0]中我输入了'a'
strncat(&symbol[0][0],"1",1);
should give the output as a1 buti know the size of symbol[0][0] is 1 byte thats why itsshowing output only a how to increase the size of symbol[0][0] sothat it can show the desired output a1 应该将输出表示为a1,但是我知道symbol [0] [0]的大小为1个字节,这就是为什么其显示输出仅显示如何增大symbol [0] [0]的大小,以便可以显示所需输出a1的原因
Try this 尝试这个
strncat(symbol[0],"1",1);
int main()
{
int i,n=1;
char symbol[100][100];
for(i=0;i<n;i++)
{
printf("enter the symbol\n");
strcpy(symbol[0],"a");
}
strncat(symbol[0],"1",1);
printf(symbol[0]);
return 0;
}
Make changes as required..:).. 根据需要进行更改.. :)。
a1
is composed of character a
and character 1
. a1
由字符a
和字符1
。 So if you'd like to have a matrix for double-characters wide symbol, you can declare a 3D array like 因此,如果您想要一个矩阵来容纳双字符宽的符号,则可以声明一个3D数组,例如
char symbol [100][100][2];
then 然后
scanf("%c%c", &symbol[0][i][0], &symbol[0][i][1]);
BTW: Well, a single element
, or symbol
you referred, can be composed of elementary element or symbol of internal type of C/C++. 顺便说一句,好吧,一个
element
或您引用的symbol
可以由C / C ++内部类型的基本元素或符号组成。 So is a1
in your question a name of variable or the value? 那么,您的问题中的
a1
是变量的名称还是值?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.