Здравствуйте.
Прошу посмотреть следующую программу и сказать, как можно её изменить, чтобы считать строку >= 256 символов
#include <stdio.h> #include <malloc.h> #include <stdlib.h> #include <string.h> #define BUF 1024 typedef struct node { char* data; struct node* next; } Node; typedef struct list { Node* root; size_t size; } List; int printList( List* list ) { Node* tmpList = list->root; printf("List:\n"); if ( NULL == tmpList->next ) printf( "%s\n", "List is empty..." ); else { tmpList = tmpList->next; while( NULL != tmpList ) { printf( "%s", tmpList->data ); tmpList = tmpList->next; } } return 0; } List* makeRoot( List* list ) { list = (List*)malloc(sizeof(List)); list->root = (Node*)malloc(sizeof(List)); list->root->next = NULL; list->root->data = NULL; list->size = 0; return list; } Node* makeElem(char * str) { Node* node = NULL; size_t lenght = strlen(str); node = (Node*)malloc(sizeof(List)); node->data = (char*)malloc(lenght*sizeof(char)+(size_t)1); node->data = strcpy(node->data, str); return node; } List* insert(char * str, List * list) { Node* point = NULL; if(NULL == list->root->next) { list->root->next = makeElem(str); } else { for(point = list->root; point->next != NULL; point = point->next){} point->next = makeElem(str); } return list; } void deleteList( List* list ) { Node* point1 = list->root; Node* point2 = list->root; while( point2 ) { point1 = point2->next; free(point1->data); free(point1); point1 = point2; } free(list); } void getString( char* str ) { char c; int i = 0; while ( '\n' != c ) { c = getchar(); str[i++] = c; } } void stringScanf( char* str ) { scanf( "%s", str ); str[ strlen(str) ] = '\n'; } int main() { char str[BUF] = {0}; size_t size = 0; List* list = NULL; list = makeRoot(list); //fgets(str, BUF, stdin); //getString( str ); stringScanf( str ); while( '.' != str[0] ) { list = insert(str, list); //fgets(str, BUF, stdin); //getString(str); stringScanf( str ); } printList(list); //deleteList(list); return 0; }