All pastes #1902088 Raw Edit

FB Converter

public cpp v1 · immutable
#1902088 ·published 2010-07-16 23:07 UTC
rendered paste body
#include <iostream>#include <fstream>using namespace std;int main(){	//Get type to fill in later:	cout<<"Warentyp angeben:"<<endl;	int type;	cin>>type;	char typestr[2]; //converted type integer	itoa(type,typestr,10); //...	char line[50]; //reading buffer	//open input file:	ifstream file;	file.open("input.txt");	//FB syntax stuff:	int currentID=0;	if(file.is_open()) //file exists	{ 		while(file.getline(line,50))		{			//Split up line into fragments:			char * splitted;			splitted=strtok(line,"-");			splitted=strtok(NULL,"-");			//Setup strings:			char writeline[50]; //line to be written			char idstr[10]; //converted currentID integer			itoa(currentID,idstr,10); //...			//construct: ID_Name=line\nID_Type=0\nID_Value=splitted\n:			strcpy(writeline,"\r");			strcat(writeline,idstr);			strcat(writeline,"_Name=");			strcat(writeline,line);			strcat(writeline,"\n");			strcat(writeline,idstr);			strcat(writeline,"_Type=");			strcat(writeline,typestr);			strcat(writeline,"\n");			strcat(writeline,idstr);			strcat(writeline,"_Value=");			strcat(writeline,splitted);			strcat(writeline,"\n");			printf(writeline);			//next ID:			currentID++;						//append current 3 lines to file:			ofstream of("output.txt",ios::app);			of<<writeline;			of.close();		}	}	else	{		cout<<"Datei \"input.txt\" nicht gefunden!"<<endl<<endl;		system("pause");		return 0;	}	//close input file:	file.close();	cout<<endl<<"Werte erfolgreich in \"output.txt\" geschrieben."<<endl<<endl;	system("pause");	return 0;}