#include "upper_lower.h"
#define VALUE 1024
class Tekst
{
char firstWord[VALUE], secondWord[VALUE]; // Dane przekazane
char firstChar, secondChar; // w funkcjach wewnętrznych
char array[VALUE]; // Dane
int menu; // operacyjne
string data; // Operacje
string operationFile; // na pliku
public:
Tekst()
{
}
void operationChangeChar() //Do funkci potrzebne array
{
ERROR:
cout<<("Chcesz zmienic slowo czy znak?")<<endl;
cout<<("Znak - 1")<<endl;
cout<<("Slowo - 2")<<endl;
cin>>menu;
if(menu==1)
{
cout << "Jaki znak zamienic" << endl;
cin >> firstChar;
cout << "Na jaki znak zamienic:" << endl;
cin >> secondChar;
data=operationChangingChar(firstChar, secondChar, array); //*
}
else if(menu==2)
{
cout << "Jakie slowo zamienic" << endl;
cin >> firstWord;
cout << "Na jakie slowo zamienic:" << endl;
cin >> secondWord;
data=operationChangingWord(firstWord, secondWord, array); //*
}
else
{
cout<<"Podano bledny znak"<<endl;
cout<<"ERROR"<<endl;
goto ERROR;
}
char tab1[operationFile.size()+1]; // Przekopiowanie stringa
strcpy(tab1, operationFile.c_str()); // na tablice operacyjną jednorazową
for(int lenght=0;tab1[lenght]!='\0';lenght++)
{
array[lenght]=tab1[lenght];
}
cout<<("Wynik operacji: ")<<(array)<<endl;
cout<<(" ")<<endl;
}
void uploadChar() //Funkcja nic nie potrzebuje
{
ERROR:
cout<<("Aby pobrać ciąg znaków z klawiatory - 1")<<endl;
cout<<("Aby pobrać ciąg znaków z pliku - 2")<<endl;
cin>>menu;
if(menu==1)
{
cout<<"Podaj slowo lub zdanie: "<<endl;
cin.getline(array,VALUE);
cout<<("Slowo: ")<<array<<endl;
}
else if(menu==2)
{
ifstream newFile;
cout<<("Jeśli chcesz wczytać dane z pliku stworz plik o nazwie: dane.txt i wpisz do niego tekst.")<<endl;
cin.ignore();
cin.get();
newFile.open("dane.txt");
if(newFile.is_open())
{
while(newFile.good())
{
getline(newFile, data);
cout<<("Pobrano:")<<data<<endl;
if(!(data.empty()))
{
operationFile=data;
}
}
}
else
{
cout<<"Błąd! Nie można otworzyć pliku!"<<endl;
}
newFile.close();
char tab2[operationFile.size()+1]; // Przekopiowanie stringa
strcpy(tab2, operationFile.c_str()); // na tablice operacyjną jednorazową
for(int lenght=0;tab2[lenght]!='\0';lenght++)
{
array[lenght]=tab2[lenght];
}
}
else
{
cout<<"Podano bledny znak"<<endl;
cout<<"ERROR"<<endl;
goto ERROR;
}
}
void saveToFile()
{
fstream file("wynik.txt",ios::out);
file<<array;
file.close();
cout<<("Dane zapisane")<<endl;
cout<<(" ")<<endl;
}
void startStrtoUpper()
{
cout<<("Wynik operacji: ")<<(strtoupper(array))<<endl;
cout<<(" ")<<endl;
}
void startStrtoLower()
{
cout<<("Wynik operacji: ")<<(strtolower(array))<<endl;
cout<<(" ")<<endl;
}
};
class Menu
{
int menu;
public:
Menu()
{
}
void displayMenu()
{
cout<<("Co chcesz zrobic?")<<endl;
cout<<(" ")<<endl;
cout<<("Powiekszyc znaki-1")<<endl;
cout<<("Zmniejszyc znaki-2")<<endl;
cout<<("Zmienic znak lub slowo-3")<<endl;
cout<<("Zapisac wyniki do pliku-4")<<endl;
cout<<("Wpisz 5 aby zakonczyc")<< endl;
cout<<(" ")<<endl;
}
int chooseOperation()
{
ERROR:
cin>>menu;
if(menu==5)
{
return 5;
}
Tekst tekst;
switch(menu)
{
case 1:
tekst.startStrtoUpper();
break;
case 2:
tekst.startStrtoLower();
break;
case 3:
tekst.operationChangeChar();
break;
case 4:
tekst.saveToFile();
break;
case 5:
{
cout<<"Koniec programu";
return 5;
}
break;
default:
{
cout<<"Podano bledny znak";
cout<<"ERROR";
goto ERROR;
}
break;
}
};
class Edytor
{
int endLoop;
public:
Edytor()
{
}
int uruchom()
{
Tekst uploadArray;
uploadArray.uploadChar();
Menu menu;
menu.displayMenu();
endLoop=menu.chooseOperation();
return endLoop;
}
};
int main()
{
Edytor start;
int operation;
while(operation!= 5)
{
operation=start.uruchom();
}
return 0;
}
#ifndef upper_lower_H
#define upper_lower_H
#include <iostream>
#include <cstring>
#include <string>
#include <fstream>
using namespace std;
char * strtolower(char input_array[]);
char * strtoupper(char input_array[]);
char * operationChangingChar(char firstChar, char secondChar, char input_array[]);
char * operationChangingWord(char firstWord[], char secondWord[], char input_array[]);
#endif
Jest jeszcze trzeci plik ,gdzie są funkcje i make-file. Wyrzuca błąd o treści:
error: expected ‘}’ at end of input
}
^
error: expected unqualified-id at end of input
O co chodzi?