Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何用c语言创建给定代码的表?_C - Fatal编程技术网

如何用c语言创建给定代码的表?

如何用c语言创建给定代码的表?,c,C,我们如何在一个表中安排它,使地址值和名称显示在适当的行和列中 #include <stdio.h> #include <stdlib.h> #include <conio.h> int main() { int tuna = 20; printf("Adress \t Name \t Value \n"); printf("%p \t %s \t %d \n",&tuna , "tuna", tuna); int * pTuna = &tun

我们如何在一个表中安排它,使地址值和名称显示在适当的行和列中

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main() {
int tuna = 20;
printf("Adress \t Name \t Value \n");
printf("%p \t %s \t %d \n",&tuna , "tuna", tuna);

int * pTuna = &tuna;

printf("%p \t %s \t %d \n", pTuna, "tuna", tuna);
printf("%p \t %s \t %p \n", &pTuna, "tuna", pTuna);


_getch();
return 0;
}
#包括
#包括
#包括
int main(){
int=20;
printf(“地址\t名称\t值\n”);
printf(“%p\t%s\t%d\n”和金枪鱼,“金枪鱼”,金枪鱼);
int*pTuna=&tuna;
printf(“%p\t%s\t%d\n”,pTuna,“金枪鱼”,金枪鱼);
printf(“%p\t%s\t%p\n”、&pTuna,“金枪鱼”,pTuna);
_getch();
返回0;
}

我修改了你的程序如下。此处
%-15
确保数据将以15个字符的字段左缩进打印。当然,我在这里的假设是数据将适合15个字符的字段。您可能需要根据您的要求进行更改

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main() {
int tuna = 20;
printf("%-15s %-15s %-15s \n","Address","Name","Value");
printf("%-15p %-15s %-15d \n",&tuna , "tuna", tuna);

int * pTuna = &tuna;

printf("%-15p %-15s %-10d \n", pTuna, "tuna", tuna);
printf("%-15p %-15s %-15p \n", &pTuna, "tuna", pTuna);


_getch();
return 0;
}

我希望这就是您要查找的内容。

这里,语句打印字符串,但至少打印15个字符(
“%-15s%-15s%-15s”
)。如果字符串较小,则在末尾添加“空白”。因此,它看起来是“有序的”

printf("%-15s %-15s %-15s \n","Address","Name","Value");
printf("%-15p %-15s %-15d \n",&tuna , "tuna", tuna);

int * pTuna = &tuna;

printf("%-15p %-15s %-10d \n", pTuna, "tuna", tuna);
printf("%-15p %-15s %-15p \n", &pTuna, "tuna", pTuna);

每个字段的最大长度是多少?变量的存储地址可以是随机的,但-15 in(%-15p)基本上代表什么?@MAhmadRana
-15
表示数据将以左缩进的方式显示在15个字段中。正如我上面所说,-15表示它将打印15个字符,但因为例如“tuna”没有15个字符,只有4个字符,您应该知道它会在其周围添加空格字符,直到长度为15个字符。
printf("%-15s %-15s %-15s \n","Address","Name","Value");
printf("%-15p %-15s %-15d \n",&tuna , "tuna", tuna);

int * pTuna = &tuna;

printf("%-15p %-15s %-10d \n", pTuna, "tuna", tuna);
printf("%-15p %-15s %-15p \n", &pTuna, "tuna", pTuna);