作者sctivcrmn (呆呆)
看板C_and_CPP
标题[语法] 看不懂的程式码
时间Mon May 18 22:17:53 2009
关於动态记忆分布:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
unsigned int no_of_size;
int *ptint,i;
cout<<"Input no of data :\n";
cin>>no_of_size;
ptint=(int *)calloc(no_of_size,sizeof(int));
if( ptint == NULL)
{
cout<<"No memory space for input data \n";
exit(1);
}
cout<<"Input the integer data \n";
for(i=0; i< no_of_size; ++i)
cin>>*(ptint+i);
cout<<"The input integer data are :\n";
for(i=0; i < no_of_size; ++i)
cout<<*(ptint+i)<<", ";
cout<<"\n";
free(ptint);
return 0;
}
我真的看不懂这个程式在做什麽... T^T
烦请高手解惑
感谢 m(_ _)m
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.218.78
1F:推 yoco315:哪边看不懂 05/18 22:41
2F:→ sctivcrmn: ptint=(int *)calloc(no_of_size,sizeof(int)); 05/18 22:44
3F:→ sctivcrmn:*(ptint+i)是指ptint[i]吗? 05/18 22:46
4F:→ sctivcrmn:if( ptint == NULL) 05/18 22:54
5F:推 ianfang:取得no_of_size个int大小的空间assign给ptint这个指标 05/19 01:00
6F:→ ianfang:是 05/19 01:00
7F:→ ianfang:如果没要到空间ptint会是NULL 05/19 01:01
8F:→ ianfang:要检查 that all 05/19 01:01
9F:→ sctivcrmn:感谢楼上! 05/19 06:15