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.