linux中c char数组的的限制是多少?
因为要pingpong测试, 所以需要用到一个很大的数组, 于是发现在linux上的数组的大小有个最大限制, 我得到的限制是一个数组最多能有999999个元素, 超过这个限制, 就会报错: Segmentation fault.
下面是我的源程序和测试环境, 请知情者相告.
#include<stdio.h>
int main(int *argc, char *argv[])
{
printf("the argv[1] is :%s\n ", argv[1]);
long int array_size = (long int)atoi(argv[1]);
char my_array[array_size];
printf("the size of my_array is : %ld \n", sizeof(my_array));
}
**@compu:~/cProg$ ./myarray 9000000
the argv[1] is :9000000
Segmentation fault
测试环境:
Debian GNU/Linux 3.1 2.6.8-3
gcc version 3.3.5 (Debian 1:3.3.5-13)
下面是我的源程序和测试环境, 请知情者相告.
#include<stdio.h>
int main(int *argc, char *argv[])
{
printf("the argv[1] is :%s\n ", argv[1]);
long int array_size = (long int)atoi(argv[1]);
char my_array[array_size];
printf("the size of my_array is : %ld \n", sizeof(my_array));
}
**@compu:~/cProg$ ./myarray 9000000
the argv[1] is :9000000
Segmentation fault
测试环境:
Debian GNU/Linux 3.1 2.6.8-3
gcc version 3.3.5 (Debian 1:3.3.5-13)
...全文
相关推荐
Linux下C语言将字符串格式(char*)或char[]的MAC地址转换为十六进制数组
Linux下用C语言将一个字符串格式(char*)的MAC地址转换为十六进制数组,代码简洁可直接使用
IT公司笔试\linux c网络网络编程面试题收集
IT公司笔试\linux c网络网络编程面试题收集 ,很全面的,我师兄传给我的
Linux C字符串,字符数组,结构体常用操作
Linux C 开发中有关 字符串,字符数组,结构体常用操作总结
C语言获取Linux系统精确时间的方法
下面小编就为大家带来一篇C语言获取Linux系统精确时间的方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
linux C程序中获取shell脚本输出(如获取system命令输出)
linux C程序中获取shell脚本输出(如获取system命令输出)


