Pagini recente » Cod sursa (job #1361051) | Cod sursa (job #1705616) | Cod sursa (job #3036438) | Cod sursa (job #1357747) | Cod sursa (job #1360788)
#include <iostream>
#include <stdio.h>
#include <fstream>
using namespace std;
int main()
{
char ch;
FILE *input;
input = fopen("convertor.in", "r");
FILE *output;
output = fopen("convertor.out", "w");
while((ch = fgetc(input)) != '}'){
if(ch == '\"'){
ch = fgetc(input);
while(ch != '\"') {
fputc(ch,output);
ch = fgetc(input);
}
fputc(',', output);
}
else if(ch == ':'){
ch = fgetc(input);
while(ch == ' ' || ch == '\n'){
ch = fgetc(input);
}
if ( ch == '"'){
ch = fgetc(input);
while(ch != '"'){
ch = fgetc(input);
}
}
}
}
fclose(input);
FILE *input2;
input2 = fopen("convertor.in", "r");
while((ch = fgetc(input2)) != EOF){
if(ch == '{')
fputc('\n', output);
if(ch == ':'){
ch = fgetc(input2);
while(ch == ' ' || ch == '\n'){
ch = fgetc(input2);
}
if(isdigit(ch))
while(ch != ' ' && ch != ',' && ch != '}' && ch != '\n'){
fputc(ch, output);
ch = fgetc(input2);
}
else
if ( ch == '"'){
ch = fgetc(input2);
while(ch != '"'){
fputc(ch, output);
ch = fgetc(input2);
}
}
fputc(',', output);
}
}
fclose(input2);
fclose(output);
return 0;
}