Cod sursa(job #1349671)

Utilizator achirialexAlexandru Achiritoaei achirialex Data 20 februarie 2015 13:14:34
Problema Convertor Scor 0
Compilator c Status done
Runda rosedu_cdl_2015 Marime 0.55 kb
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main(void){
	freopen("convertor.in", "r", stdin);
	int cap = 1024;
	int cont = 0;
	char *text = (char*)malloc(cap * sizeof(char));
	char buffer[1024];
	while(gets(buffer)){
		cont = cont + strlen(buffer) + 1;
		if(cont >= cap){
			cap  = cap * 2;
			text = (char*)realloc(text, cap * sizeof(char));
		}
		strcat(text, buffer);
	}
	char *token;
	token = strtok(text, "}");
	while(token != NULL){
		printf("%s\n", token);
		token = strtok(0, "}");
	}
//	printf("%s", text);
	return 0;
}