I've searched for the solution online and throughout the forums but couldn't find anything that helped me (although I may have looked over it and simply not understood.) I'm having trouble getting past input in my program, where it takes input and then just stops, as if it's processing, and won't respond to anything other than killing the program. Here is my code:
You are assigning boolean values to variables within your loop conditions. Try while(reset == true) instead of while(reset = true) in line 7. Also in line 25
I've changed a few things around, hoping to have fixed the problem. I've changed all my bool expressions from (bool = true) to (bool == true), and I've initialized test before using it as I was getting a fatal error because of it. Still getting the same problem.
if (!(binaryValue[i] == 0 || binaryValue[i] == 1)||binaryValue.length() > 16)
Testing individual characters of a string for digits one and zero should look like this: (binaryValue[i] == '0')
notice the single quotes around the character.
There's no need to repeatedly test the string length inside the for-loop, just do it once, before the loop begins.
I don't see that you've have you declared binaryValue as an array, because you're accessing an array within line 16.
I know string's can be arrays of characters but I don't think that fact applies to this instance.
Try for line 5
1 2 3 4 5 6 7
int i;
string temp;
string* binaryValue;
cout << "\nEnter a binary value containing up to 16 digits: ";
cin >> temp;
i = temp.length();
binaryValue= newint[i];
don't forget, when you want to discard binaryValue use:
This revelation would have made my replace all vowels in a string program soooo much easier. Thanks Chervil, I learn something new from you everyday! If you don't mind me asking what resources(books, tuts?) did you use to learn C++?
My vowels solution :(
1 2 3 4 5 6 7 8 9
for (int i=0; i < name.length(); i++)
{
for (int x=0; x < 6; x++) {
vowel = vowelArr[x];
found = name.find(vowel);
if (found!=string::npos)
name.replace(found, 1, "z");
}
}
what resources(books, tuts?) did you use to learn C++?
That's difficult to answer, as I learned other languages first, and could apply some previous knowledge during the learning process.
However, I do recommend getting a good book (or several!) and work through them carefully. I find the reference section on this site has been very helpful (though it is still useful to look elsewhere too).