For one of my projects i'm creating I made a course database file with some keywords in it to let me know if I reach that line then to delete everything until I reach the next line found. In this case the lines are "Descriptionstart" and "Descriptionend". I can't really change the file because i'm way too far in the development to change anything in the file. Here's what I have so far: I pretty much run the program and type in "Computer Logic Circuits" then it deletes all the lines until "Descriptionstart". What I have commented out is what i'm playing around with and running through debugger to see whats happening. But its kinda messy at this point
int main()
{
ifstream myfile("coursedatabase.csv");
ofstream myfile2("outfile.csv");
string line;
string temp = "";
int skip = 0;
string dropcourse;
//string name = "Computer Logic Circuits";
cout << "Enter course to drop by course name: ";
getline(cin, dropcourse);
while (getline(myfile, line))
{
if ((line != dropcourse) && !(skip > 0))
{
myfile2 << line << endl;
}
else
{
if (skip == 0)
{
skip = 4;
}
else
{
--skip;
}
}
/*if (line == "Descriptionstart")
{
while (getline(myfile, line))
{
if (line == "Descriptionend")
{
}
}
myfile2 << line << endl;
}*/
}
myfile.close();
myfile2.close();
remove("coursedatabase.csv");
rename("outfile.csv", "coursedatabase.csv");
}
Here is a sample of the courses in the list.
start
Electric Circuit Theory I
ENGI-1236-FA
Year 1
2
0
Descriptionstart
Fundamentals of electromagnetism and circuit analysis; network theorems;
properties of resistors, capacitors and inductors; transients in RL and RC networks;
introductory magnetic circuits and ideal op-amp circuit analysis.
Descriptionend
Dr. Laura Curiel
end
start
Computer Logic Circuits
ENGI-1637-FA
Year 1
2
0
Descriptionstart
Introduction to fundamental concepts of digital logic circuits and design with Verilog HDL. Topics include
principles of number systems, operations, codes, logic gates, Boolean algebra and logic simplification, PAL
and PLD based combinational logic functions, synchronous and asynchronous logic circuits, state transition
diagrams, latches, flip-flops, counters, shift registers, memory, Mealy and Moore finite state machines.
Descriptionend
Dr. Ehsan Atoofian
end
start
Intro to Microcontrollers
ENGI-1232-WA
Year 1
2
0
Descriptionstart
Hardware and software aspects of microcontrollers and their applications in embedded systems; assembly
language programming; architecture and addressing structures; serial and parallel input/output interfaces;
timer programming; memory interfacing; interrupts and interrupt service routines; programming in C for
microcontrollers; ADC, DAC and sensor interfacing.
Descriptionend
Dr. Ehsan Atoofian
end
Aucun commentaire:
Enregistrer un commentaire