Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

Aaron Knox

@Aaron Knox
About
Posts
4
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • switch statement
    A Aaron Knox

    Hi all, I'm still working on my switch statement program (from previous post)thanks to Joaquin my loop is working but for some reason my switch statements are not being activiated. I've included a portion of my code, the switch statements continue for each letter a state begins with (d,f,g,h,i,k,etc) Thanks, Aaron //this program is supposed to read state abbreviations from a file and output the corrosponding state to another file #include #include using namespace std; int main() { ifstream inAbrev("state abs.txt"); //opens the input file ofstream outState("states with abvs.txt"); //opens the output file char firstLetter, secondLetter; inAbrev >> firstLetter >> secondLetter; cout << firstLetter << secondLetter << endl; //just for me to see if anything is happening while(inAbrev) //read til the end of the file { inAbrev >> firstLetter >> secondLetter; cout << firstLetter << secondLetter << endl; switch (firstLetter) { case 'A' : switch (secondLetter) { case 'L' : outState << inAbrev << " is " << "Alabama" << endl; cout << inAbrev << " is " << "Alabama" << endl; //here i'm trying to see if anything is happening break; case 'K' : outState << inAbrev << " is " << "Alaska" << endl; break; case 'Z' : outState << inAbrev << " is " << "Arizona" << endl; break; case 'R' : outState << inAbrev << " is " << "Arkansas" << endl; break; } case 'C' : switch (secondLetter) { case 'A' : outState << inAbrev << " is " << "California" << endl; break; case 'O' : outState << inAbrev << " is " << "Colorado" << endl; break; case 'T' : outState << inAbrev << " is " << "Connecticut" << endl; break; } arrrgh

    C / C++ / MFC

  • Switch statement and while loop
    A Aaron Knox

    Thanks Joaquin, my while loop now works. However for some reason my switch statements are not being run. If you or anyone has any suggestions it would be great. Thanks again, Aaron arrrgh

    C / C++ / MFC help regex

  • Switch statement and while loop
    A Aaron Knox

    I'm trying to write a program that reads state abbreviations from an input file and then outputs the corrosponding state to an output file. (this is my first class in programming) I'm using a while loop that runs until the end of input file and switch statements to match states and abbreviations, here is a portion... inAbrev >> firstLetter >> secondLetter; //splits abbreviation into two char's while(inAbrev) //read til the end of the file, inAbrev is the ifstream { switch (firstLetter) //checks first letter of abbreviation and tries to match it to working cases //I have one of these for each letter that a state name begins with { case 'A' : switch (secondLetter) { case 'L' : outState << inAbrev << " is " << "Alabama" << endl; //outState is the break; //output file case 'K' : outState << inAbrev << " is " << "Alaska" << endl; break; case 'Z' : outState << inAbrev << " is " << "Arizona" << endl; break; case 'R' : outState << inAbrev << " is " << "Arkansas" << endl; break; } I can get it to compile but my loop (and maybe my switch statements) seems to be wrong. The problem is that it gets stuck on the first input (AL) and goes into an infinite loop of just reading that input, it is never evaluated and nothing is output. I'm probably missing something simple but my beginners brain can't find it. Any help would be great. Thanks, Aaron arrrgh

    C / C++ / MFC help regex

  • decimal fraction conversion
    A Aaron Knox

    Hello All, I need to be able to convert decimal numbers into fraction form. I understand how to do this mathematically but I'm not sure how to put it into code. Thanks for your help Aaron :beer

    C / C++ / MFC help tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups