Is this way im writing to a file bad?

Im just wondering if the way im writing to a file is bad and if so, if there is a cleaner way i could do it. The section of my code im talking about is inside a switch statement and its as simple as it looks, if the case is "0" then it just writes all of this into the file.

1
2
3
4
5
6
7
8
case 0:

File << "Whatever" << endl;
File << "Whatever" << endl;
File << "Whatever" << endl;

//imagine 181 lines of basically this with a few variables here and there.
break;

imagine 181 lines of basically this with a few variables here and there.


What exactly are you trying to do here? I'm sure there is an easier way than writing out 181 lines of code.

1
2
3
4
5
6
7
8
case 0: {

File << "Whatever" << endl;
File << "Whatever" << endl;
File << "Whatever" << endl;

//imagine 181 lines of basically this with a few variables here and there.
} break;

Most people add brackets when their case has more than one line. It doesn't have to be there, but I think it makes things look neater.
Im really just wondering if there is a better way to optimize the code or if i already have it as good as it can get.
Why not tell us what you are trying to code here? I don't know if you are hard-coding it or you have to do it this way.
Its a starcraft 2 bank generator hack, its already fully working im just cleaning up the code at this point. And no it dosent really have to be like this but i dont see another way to do it that would make it easier.
Last edited on
Why do you have to write to a file 181 times for a bank hack?
Its a big damn bank file compared to most. XML file.
Topic archived. No new replies allowed.