系统相关
首页 > 系统相关> > 王道oj/problem12(动态申请内存存储数组)

王道oj/problem12(动态申请内存存储数组)

作者:互联网

网址:http://oj.lgwenda.com/problem/12

思路:用输入的整型创建对应数组,用scanf消除换行键;

          用gets()输入语句并输出,再释放。

代码:

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int n;
char c;
scanf("%d", &n);
char* p;
p = (char*)malloc(n);
scanf("%c", &c);
gets(p);
puts(p);
free(p);
p = NULL;
return 0;
}

标签:gets,oj,problem12,scanf,char,内存,数组,include
来源: https://www.cnblogs.com/zcctxr/p/16115035.html