Home > Back-end >  [for] method function error (devcpp)
[for] method function error (devcpp)

Time:11-03

//
#include
#include
//# include "ph_del. H"
#include
#include
//# include & lt; Fstream>
using namespace std;

Void method (int meth, string folder, string ss, string origin);
String input_path (string * file_name);
Bool input_file (char * c, string * ss);
Void reject (string * ss);
Bool save (string file_name, string ss, string origin);
String del_space (ret) string ss, int *;
String sim_sen (string ss);

Int main ()
{
String file_name;
String ss;
String path=input_path (& amp; File_name);
Char * c=(char *) path. C_str ();
if(! Input_file (c, & amp; Ss)) return 0;

String origin=ss;
Reject (& amp; Ss);
Save (file_name, ss, origin);

return 0;
}

Void method (int meth, string folder, string ss, string origin)
{

The switch (meth)
{
Case 1:
//string path_1=
Ofstream fout_1 ((char *) (+ "Normal. Docx" folder). C_str (), the ios: : out);
Fout_1 & lt; Fout_1. Close ();
break;
Case 2:
Ofstream fout_2 ((char *) + "Simple Sentence. Docx" (folder). The c_str (), the ios: : out);
Fout_2 & lt; Fout_2. Close ();
break;
Case 3:
Ofstream fout_3 ((char *) + ". The Original docx "(folder). The c_str (), the ios: : out);
Fout_3 & lt; Fout_3. Close ();
break;
Case 4:
Ofstream fout_4 ((char *) (+ "Non - space. Docx" folder). The c_str (), the ios: : out);
int i;
String SSS=del_space (& amp; Ss, & amp; I);
Fout_4 & lt; Fout_4. Close ();
break;
Default:
Ofstream fout_faulty ((char *) (folder + "ERROR. TXT"). The c_str (), the ios: : out);
Fout_faulty. Close ();
}

return;
}

String input_path (string * file_name)
{
String path;
cout<& lt;" Both Please enter the path: "; Cin> The path;

Int slash_pos=path. Rfind ('/');
If (slash_pos==1)
{
Slash_pos=path. Rfind (' \ \ ');
Slash_pos +='\ \';
}
The else
{
Slash_pos +='/';
}

Int dot_pos=path. Rfind (');
* file_name=path. Substr (slash_pos + 1, dot_pos slash_pos - 1);
Return path.
}

Bool input_file (char * c, string * ss)
{
String s;

Ifstream fin (c, the ios: : in);
if(! Fin)
{
cout<& lt;" Not found!!!!!! \ "a & lt; return false;
}

Int CNT=0;
While (getline (fin, s, '\ n'))
{
Cnt++;
* ss +=s;
* ss +='\ n';
}
Fin. The close ();
return true;
}

Void reject (string * ss)
{
Int start_pos=ss - & gt; Find ('/');
If (start_pos!=1)
{
Int finish_pos=ss - & gt; Find ('] ');
Ss - & gt; Erase (start_pos finish_pos);
}
}

Bool save (string file_name, string ss, string origin)
{
String save_path;
cout<& lt;" Both Please enter the save path: "; Cin> Save_path;

String meth_store;
cout<& lt;" Both Please choose the method of storage: Space off) "& lt; cout<& lt;" 1. Normal \ t 2. Simple Sentence "& lt; cout<& lt;" 3. The Original \ t 4. Non - space & lt;" Cin> Meth_store;

Int a [4]={0}; Int ia=0;
for(int i=0; i{
If (meth_store [I] <='9' & amp; & Meth_store [I] & gt;='0')
A [ia++]=meth_store [I] - '0';

The else continue;
}

String folder=save_path + file_name;
_mkdir ((const char *) folder. C_str ());
for(int i=0; A [I]!=0; I++)
Method (a [I], folder, ss, origin);

return true;
}

String del_space (ret) string ss, int *
{
Int I=0;
Int CNT=3;


While (CNT)
{
Char a=ss [I];
If (a=='\ n') CNT -;
}
* ret=I;
For (; i{

If (ss [I]=='\ n');
Ss. Erase (I, 1);
}
Return ss;
}

String sim_sen (string ss)
{
Vector Sentence;
Int start_i;
Ss=del_space (ss, & amp; Start_i);

Int CNT=0;
The string to add;
For (int I=start_i; i{
If (ss [I]=')
{
Sentence. The push_back (add + '\ n');
Add the clear ();
Cnt++;
}
The else
{
The add +=ss [I];
}
}

String ret.
Ret +=ss. Substr (0, start_i);
for(int i=0; i{
Ret +=what [I];
}
return ret;
}


Error:
C: \ Users \ YuLiNa \ Desktop \ Photo_delete CPP In function 'void method (int, STD: : string, STD: : string, STD: : string)' :
44 8 C: \ Users \ YuLiNa \ Desktop \ Photo_delete CPP [Error] jump to case label [- fpermissive]
40 13 C: \ Users \ YuLiNa \ Desktop \ Photo_delete CPP [Error] crosses initialization of 'STD: : ofstream fout_1'
49 8 C: \ Users \ YuLiNa \ Desktop \ Photo_delete CPP [Error] jump to case label [- fpermissive]
45 13 C: \ Users \ YuLiNa \ Desktop \ Photo_delete CPP [Error] crosses initialization of 'STD: : ofstream fout_2'
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related