Pagini recente » Cod sursa (job #3199090) | Cod sursa (job #1741072) | Cod sursa (job #2397648) | Cod sursa (job #1342494) | Cod sursa (job #1359592)
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
FILE *file,*out,*file2;
char *str1 = malloc(110000*sizeof(char));
char *str2 = malloc(110000*sizeof(char));
int i = 0,j = 0;
char c;
file = fopen("convertor.in","r");
out = fopen("convertor.out","w");
c = fgetc(file);
while(c != '}')
{
while(c != '"' && c != EOF)
c = fgetc(file);
c = fgetc(file);
while(c != '"' && c != EOF)
{
str1[i] = c;
c = fgetc(file);
i++;
}
str1[i] = ',';
i++;
while(c != ',' && c != '}')
c = fgetc(file);
}
fprintf(out,"%s\n",str1);
free(str1);
fclose(file);
file2 = fopen("convertor.in","r");
c = fgetc(file2);
while(c != ']' && c != EOF)
{
while(c != ':' && c != EOF)
c = fgetc(file2);
c = fgetc(file2);
while(c == ' ' && c != EOF)
c = fgetc(file2);
if(c == '"' && c != EOF)
{
c = fgetc(file2);
while(c != '"' && c != EOF)
{
str2[j] = c;
j++;
c = fgetc(file2);
}
str2[j] = ',';
j++;
}
else
if(c != EOF)
{
while(c != ',' && c != ' ')
{
str2[j] = c;
j++;
c = fgetc(file2);
}
str2[j] = ',';
j++;
}
while(c != ':' && c != '}' && c != ']' && c != EOF)
c = fgetc(file2);
if(c == '}' && c != EOF)
{
fprintf(out,"%s\n",str2);
j = 0;
free(str2);
str2 = malloc(110000*sizeof(char));
}
}
free(str2);
fclose(file2);
fclose(out);
}