Home > Back-end >  C using the rename variables in the program
C using the rename variables in the program

Time:11-01

Himself wrote a simple small program, I want to rename judgment conditions, but what I want is such as: variable I %==0 64, execute commands to rename, newname want to use this value (I/64 + 1), every time the point error, not clear all their self-study did kangkang which bosses solve, here are some relevant code:
 # include & lt; Iostream> 
#include
# include & lt; IO. H>
# include & lt; Stdio. H>
using namespace std;
Int main ()
{
Int a, b, y, z, m, n, p, I;
Double x;
Fstream FTXT;
Cout<& lt;" Please enter the base "& lt; Cin> a;
Cout<& lt;" Please enter the high bass "& lt; Cin> M;
If (m==1)
{
Begin1:
Cout<& lt;" Please enter you need multiple "& lt; Cin> x;
Cout<& lt;" Please enter the location notes "& lt; Cin> n;
If (n==2)
{
Cout<& lt;" "Input position & lt; Cin> p;
If (p==1)
Z=55;
If (p==2)
Z=57;
Goto begin3;
}
Else if (n==1)
{
Cout<& lt;" "Input position & lt; Cin> p;
If (p==1)
Z=59;
If (p==2)
Z=60;
Goto begin3;
}
Else if (n==1)
{
Cout<& lt;" "Input position & lt; Cin> p;
If (p==1)
Z=62;
If (p==2)
Z=64;
Goto begin3;
}
Else if (n==2)
{
Cout<& lt;" "Input position & lt; Cin> p;
If (p==1)
Z=65;
If (p==2)
Z=67;
Goto begin3;
}
Else if (n==3)
{
Cout<& lt;" "Input position & lt; Cin> p;
If (p==1)
Z=69;
If (p==2)
Z=71;
Goto begin3;
}
Else if (n==4)
{
Cout<& lt;" "Input position & lt; Cin> p;
If (p==1)
Z=72;
If (p==2)
Z=74;
Goto begin3;
}
Else if (n==5)
{
Cout<& lt;" "Input position & lt; Cin> p;
If (p==1)
Z=76;
If (p==2)
Z=77;
Goto begin3;
}
Else if (n==6)
{
Cout<& lt;" "Input position & lt; Cin> p;
If (p==1)
Z=79;
If (p==2)
Z=81;
Goto begin3;
}
Else if (n==7)
{
Cout<& lt;" "Input position & lt; Cin> p;
If (p==1)
Z=83;
If (p==2)
Z=84;
Goto begin3;
}
Else if (n==8)
{
Cout<& lt;" "Input position & lt; Cin> p;
If (p==1)
Z=86;
If (p==2)
Z=88;
Goto begin3;
}
Else if (n==9)
{
Cout<& lt;" "Input position & lt; Cin> p;
If (p==1)
Z=89;
If (p==2)
Z=91;
Goto begin3;
}
Else if (n==10)
{
Cout<& lt;" "Input position & lt; Cin> p;
If (p==1)
Z=93;
If (p==2)
Z=95;
Goto begin3;
}
Begin3:
Y=x * 8;
B=y + a;
FTXT. Open (" MC. TXT ", the ios: : out | ios: : app);
Ftxt<& lt;" The execute @ e [score_1_min="& lt; & lt; b<& lt;", score_1="& lt; & lt; b<& lt;"] ~ ~ ~ the function drops piano: "& lt; FTXT. Close ();
I=b - 8;
/* this location rename judgment and execution */
getchar();
a=b;
Goto begin1;
}

CodePudding user response:

The else if cooperate goto, ah, is show, and, considering the switch statement??
Begin1 this piece, can with circular statement,,

I didn't see you rename that where is the line of code,,

CodePudding user response:

reference 1st floor draculamx response:
the else if cooperate goto, ah, is show, and, considering the switch statement??
Begin1 this piece, can with circular statement,,

I didn't see you rename that where is the line of code, and

Ha ha ha really is more troublesome but I actually do is one according to the position output statements of music notes, the note of the change more limitations do loop statement, and I learn the switch the class is not good nice ha ha ha so this statement is not skilled,
Then rename statement I didn't write, I just want to ask how to write, I will now, but the trouble is
 if (I %==0 64 & amp; & I> 0) 
{
/* prompt for file to rename and new name */
Cout<& lt;" Please input the name "& lt; Cin> Oldname;
Cout<& lt;" Please enter a new name "& lt; Cin> Newname.
Rename (oldname, newname);
If (rename (oldname, newname)==1)
Goto begin1;
Else if (rename (oldname, newname)==0)
Cout<& lt;" Rename failure "& lt; }

Although this did I want to name but need to manually enter a name, rather than what I want the "I % 64 + 1" calculated values directly into a new file name, so use this instead of the first

CodePudding user response:

Can use the STD: : string
The string filename="MC" + to_string (I % 64 + 1) + ". TXT ".
  • Related