mhq-martin

1 整型数组

//

#include "stdafx.h"
#include "stdlib.h"

int _tmain(int argc, _TCHAR* argv[])
{
int *q=(int*)malloc(sizeof(int)*5);   //malloc函数动态分配5个整型数的地址空间。

printf("Please input:");

for(int i=0;i<5;i++)

scanf("%d",q+i);  

for(int i=0;i<5;i++) 
 
printf("%d ",*(q+i));
    system("pause");
    return 0;
}

2 定义有一个字符串进行输入输出

#include "stdafx.h"
#include "stdlib.h"

int _tmain(int argc, _TCHAR* argv[])
{
char *str=(char*)malloc(100);   //malloc函数动态分配地址空间。

printf("Please input:");

scanf("%s",str);   


printf("%s",str);   //注意 不用加 *
    system("pause"); 
    return 0;
}

 

分类:

技术点:

相关文章:

  • 2021-10-15
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
  • 2021-12-29
  • 2021-12-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2021-12-23
相关资源
相似解决方案