Name: Deimos Date: November 27, 2007 at 17:42:55 Pacific Subject: Another Simple Program Assistance OS: Windows Xp professional S CPU/Ram: CPU:2.6x2Ghz Ram:2048mbs Model/Manufacturer: Deimos's nr1
Comment:
This one was made entirely by me, but(SUPRISE!!) it has a problem. The idea is it to locate letters whitin a word and after replace the found letters by number, producing some sort of primitive code for example A = 1.
cout << "Demonstrating Array: \n"; for(int i = 0; i<ABC_NR; ++i){ for(int j = 0; j<FIELDS_NR; ++j){ cout << abc[i][j]; } cout << endl; } cout << endl; string word = "Hello"; cout << "The test word is " << word << endl; cout << "Testing Consonants\n"; for(int i = 0; i<(ABC_NR*2); ++i){ string tempC = abc[i][ABC_C]; int consonant_nr = word.find(tempC);
if(consonant_nr != string::npos){ char letterC = word[consonant_nr]; cout << "Found the consonant " << letterC << " in the word\n"; }else{ cout << abc[i][ABC_C] << " wasn't found on the word\n"; }//end if }//end for
cout << "Testing Vogals: \n"; for(int i = 0; i<(ABC_NR*2); ++i){ string tempV = abc[i][ABC_V]; int vogal_nr = word.find(tempV); if(vogal_nr != string::npos){ char letterV = word[vogal_nr]; cout << "Found the vogal(s) " << letterV << " in the word\n"; }else{ cout << abc[i][ABC_V] << " wasn't found on the word\n"; }//end if }//end for system("Pause"); }//end main()
The problem is that system("Pause") doesn't work and the app shuts down imidiatly, why? Am I giving any command that acts as the Enter Key being pressed? Or is it a more complex error?
Best Regards AMD ATHLON X2 5200 2.6ghz; ASUS M2N-E SLI; 2GB DDR800 KINGSTON; ASUS GF8600GTS; Seagate 7200rpm 320GB;
The problem is that system("Pause") doesn't work and the app shuts down imidiatly, why? Am I giving any command that acts as the Enter Key being pressed? Or is it a more complex error? You're over thinking it. The problem is a segfault; your program isn't even making it to the system("Pause");.
What Razor said is right. By the way, you're not testing consonants and "vogals" (vocals? vowels? bagels?); you seem to be testing capital letters and small letters (uppercase and lowercase in the U.S.) Are you Greek by any chance?
I'm Portuguese, we use the terms "Maiusculas" and "Minusculas", and yes, US talking, i mean to test the uppercase and the lowercase letters.(lol...what a silly error, it aint the vowels or the consonants i want to test its uppercase and lowercase...LOL)
I still haven't finished it, it still needs the Actual "word to number conversion" part of the code, i dont know if this is the best way to do it, can you give me some kind of hints?
Best Regards
AMD ATHLON X2 5200 2.6ghz; ASUS M2N-E SLI; 2GB DDR800 KINGSTON; ASUS GF8600GTS; Seagate 7200rpm 320GB;
Longer but simpler? Probably, but I can't think of it.
I guess I could have used for (int i = 0; i < s.size(); ++i) instead of the string iterator, but the iterator is so convenient (once I remember how to spell 'iterator').
I didn't use using namespace std;, which is why almost everything's prefixed by std::.
I guess I could have not used stringstream (roughly 1/3 of the program), but aside from the out.str() function, everything can be used with cout (and mostly cin), so it's nice to know.
The trickiest part of the code is the bool notSymbol(unsigned char) function. Specifically, how the mask works. To understand how it works, you need to know two things: (1) In ASCII, there's only one bit difference between upper and lower case; (2) This bit, when set to '0', is uppercase. Outside of that, you just need to know the binary operators XOR (^), inversion (~), and, well, AND (&); the logical operators AND (&&) and OR (||); as well as the comparison operators >= and <=.
How did you learn programing? I took a course or two in college, but mostly I've learned by myself, partly by trial and error, partly by visiting my local library.
- The C++ FAQ LITE is a good read, and includes book recommendations. - Join a newsgroup, possibly comp.lang.c++. - Lurk on C++ forums. Not this one, this forum is too general to be good as a C++ reference. As an added bonus, you can stop lurking long enough to ask questions! Just make sure you START by lurking. Otherwise, you won't know their mannerisms. That goes for the newsgroup option, too. Remember: Proper netiquette starts with lurking.
EDIT: Also, I recommend Visual Studio Express (I link it because MS' site becomes more atrocious with every iteration). It's one of the best IDE's I've seen, and it includes one of the best debuggers I've seen. Added bonus: MSDN documentation.
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE