69,374
社区成员
发帖
与我相关
我的任务
分享
#include <stdlib.h>
#include <stdio.h>
#define NULL 0
#define amount1 100 //结构体中*arr[]数组长度,用来定义扩充成员个数
typedef struct node
{
struct node *pre; //指向前驱
char *arr[amount1];
struct node *next; //指向后继
}NODE;
NODE *head;
#include <stdlib.h>
#include<iostream>
#include <stdio.h>
using namespace std;
#define NULL 0
#define amount1 100 //结构体中*arr[]数组长度,用来定义扩充成员个数
typedef struct node
{
struct node *pre; //指向前驱
char *arr[amount1];
struct node *next; //指向后继
}NODE;
NODE *head;
int main()
{
head = (NODE *)malloc(sizeof(NODE));
int index = 0;
char buffer[64] = {0};
while (scanf("%s",buffer) != EOF)
{
head->arr[index] = (char *)malloc(strlen(buffer) + 1);
strcpy(head->arr[index], buffer);
printf("index = %s\n",head->arr[index]);
index++;
if(getchar() == '\n')break;//读到输入的字符串的末尾了,结束循环
}
system("pause");
return 0;
}