I have just completed my first program in c++.I am an ultra newbie,have only been doing c& c++ for 12 days,so please forgive me if my program is shit.Anyways i would like the experts on this forum to evaluate my work and give me tips and hints to make myself a better programmer.

Moschops gave me a very useful way to search for strings,and although it worked on it's own http://www.daniweb.com/software-development/cpp/threads/392659/1688590#post1688590 i couldn't figure it out ,most probably because it's my 2nd day in c++.

I would like to know an analogue of

system("cls);

since
the String print i used an my first screen clearing does not reset the cursor at the top left of the screen.Also i find my program to be repetitive.I am hoping that you could help me with that
Here is my code

#include <iostream>
#include <conio.h>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include <stdio.h>


char DRL[2];
int a;
int b;

void INTRO();
void INPUT1();
void FILE_WRITING();
void OSCHECK();
void WRIT2USB();
void TERMINATUS();



using namespace std;


int main()
{
 INTRO();
INPUT1();
FILE_WRITING();
OSCHECK();
WRIT2USB();
TERMINATUS();
}

void INTRO()
{
    cout<<"\n\n\n";
    cout << "\t\t\t Make Your USB Device Bootable" << endl;
    cout<<"\t\t\t\t Coded By Sawal\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
    cout<<"Press Any Key To Continue";
    cin.get();
    cout << string(53, '\n');
}

void INPUT1()
{
    cout<<"\n\n Please Input The Drive Letter Of Your Input Device \n";
    cout<<"Please make sure that you add a colon ";
    cin>>DRL;
    cout<<DRL;



}


void FILE_WRITING()
{

    ofstream f1;
    f1.open("c:\\batch.bat");
    f1<<"@echo off\n";
    f1<<"diskpart /s c:\\script.txt\n";


    f1.close();




   ofstream sc;
   sc.open("c:\\script.txt");
   sc<<"list disk";


    sc.close();



system("c:\\batch.bat");
   cout<<"Please enter the disk number of your USB device above\n";
    cout<<"It can be found under the heading  DISK ### \n";
    cin>>a;

remove("c:\\batch.bat");
remove("c:\\script.txt");

ofstream sc1;

sc1.open("c:\\script.txt");

sc1<<"Select Disk "<<a<<"\n";
sc1<<"Clean \n";
sc1<<"Create Partition Primary \n";
sc1<<"Select Partition 1 \n";
sc1<<"Active\n";
sc1<<"Format FS=NTFS  \n";
sc1<<"Assign Letter "<<DRL<<"\n";
sc1<<"exit";

sc1.close();


}


void OSCHECK()
{
    system("cls");
    cout<<"Press[1] for windows 7 32 bit bootcode\n\n\n Press[2] for Windos 7 64 bit bootcode \n";
    cin>>b;

}


void WRIT2USB()
{




{
    system("diskpart.exe /s c:\\script.txt");
    remove("c:\\script.txt");
    ofstream ds;
    ds.open("work.bat");
    ds<<"@echo off \n" ;
    ds<<"bootsect.dll -x -y BSBIN.hex\n";
    ds.close();
    system("work.bat");
    remove("work.bat");
}
 switch(b)
{



Case1:
cout<<"Writing 32 bit bootcode";
ofstream ps;
ps.open("work32.bat");
ps<<"cd bsbin\\BS32\n";
ps<<"bootsect.exe /nt60 "<<DRL;

ps.close();
system("work32.bat");
remove("work32.bat");
break;
goto IMUM;


Case2:
cout<<"Writing 64 bit bootcode \n";
ofstream gs;
gs.open("work64.bat");
gs<<"cd bsbin\\BS64\n";
gs<<"bootsect.exe /nt60 "<<DRL;

gs.close();
system("work64.bat");
remove("work64.bat");
break;
goto IMUM;
}


{
    IMUM:

ofstream rs;
rs.open("del.bat");
rs<<"@echo off";
rs<<"cd bsbin\\bin64 \n";
rs<<"del *.* /q \n";
rs<<"cd.. \n";
rs<<"rd bin64 \n";
rs<<"cd bin32 \n";
rs<<"del *.* \n";
rs<<"rd bin32 \n";
rs<<"cd .. \n";
rs<<"rd bsbin \n";
rs<<"del del.bat \n";
rs.close();
system("del.bat");



}
}
void TERMINATUS()
{
    system("cls");
    cout<<"writing bootcode finished";

}

Your feedback will help me make myself a better programmer

Just as a footnote, This file will delete every file in your current directory.

Your feedback will help me make myself a better programmer

OK, here goes:

First and foremost, format your code properly. #include <conio.h> -- don't use it. It's not portable and there's nothing in there you really need #include <stdio.h> -- this is (supposedly) a C++ program. Don't use C headers #include <stdio.h> -- why twice? int main() -- where is your return statement? You should be getting a compiler warning. system("c:\\batch.bat"); -- why are you executing a batch file? system("cls"); -- clearing the screen is annoying to the user. You don't need to do it. break; halts execution so the next line cannot possibly be executed. goto IMUM; -- there is rarely ever a need for GOTO. Don't use them. And since you used it after break; , you can't get to it anyway. You should have compiler warnings about this.

And if you've been programming for 12 days, why are you writing a program that can f'up your system?

All in all, I consider this a terrible program. Sorry.

OK, here goes:

First and foremost, format your code properly. #include <conio.h> -- don't use it. It's not portable and there's nothing in there you really need #include <stdio.h> -- this is (supposedly) a C++ program. Don't use C headers #include <stdio.h> -- why twice? int main() -- where is your return statement? You should be getting a compiler warning. system("c:\\batch.bat"); -- why are you executing a batch file? system("cls"); -- clearing the screen is annoying to the user. You don't need to do it. break; halts execution so the next line cannot possibly be executed. goto IMUM; -- there is rarely ever a need for GOTO. Don't use them. And since you used it after break; , you can't get to it anyway. You should have compiler warnings about this.

And if you've been programming for 12 days, why are you writing a program that can f'up your system?

All in all, I consider this a terrible program. Sorry.

You're much better than me,so sorry isn't a necessity.I learned simple stuff like matrices and mathematical operators and the other stuff within the first few days.Now i am hellbent on writing a program that can be of use.I have already written this very same program in "C",Tried tested and released.Now for my first C++ project i tried rewriting it in C++.

I had to use Batch files,for the DISKPART utility.As far as i know, you cannot give instructions to the command prompt once DISKPART has started.

And also about my

System("cls");

problem,do you have any ideas.

And the break was a typo.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.