344 Posted Topics
Re: You've almost got it right. Note that it should be `int main()` and pausing at line 35 achieves nothing. Here's your code with some corrections. #include <iostream> using namespace std; int lastLargestIndex(int [], int); int main() { int arr[15] = {5,198,76,9,4,2,15,8,21,34,99,3,198,13,61,}; int location = lastLargestIndex(arr, 15); if (location != -1) … | |
Re: Personally, I find the wording of the question somewhat ambiguous. Hopefully this will help you. #include <iostream> using namespace std; int main() { int posCount = 0; int negCount = 0; int posSum = 0; int negSum = 0; int numb; cout << "Please enter any combination of ten positive\nor … | |
Re: What compiler are you using? Seeing as `printf("%%%s", registers(C))` isn't working as expected, you may need to resort to a workaround like `printf("%s%s", "%", registers(C))` | |
Re: Change lines 22 and 27 to match the function prototypes in lines 10 and 11. You need to pass the correct variable name to each function. e.g. `displayArrayVal1( x_array);` The printf lines need fixing to something like: `printf("X-array1 = %u\n", x[0]);` | |
Re: You really should be checking the return value of ReadProcessMemory, WriteProcessMemory etc. Here's your code minus the spelling mistakes and the obvious syntax errors. I've no idea if it works, I've not completely cleaned it up, but it does compile. #include <iostream> #include <Windows.h> #include <string> #include <ctime> DWORD FindDmaAddy(int … | |
Re: line 12 `while ( k <= 0)` This condition is only met when k = 0. line 14 `j=3;` This is out of bounds for your matrix, valid values are 0 to 2 inclusive. line 16 `Image1[i][k]= Image2[j][k];` This is the wrong way around. You're just copying memory junk from … | |
Re: `' '` is the space character which equals 0x20 or 32 in decimal. The rest of the code is explained here > http://www.cplusplus.com/articles/1AUq5Di1/ | |
Re: I'm not sure if this is what you mean, but try `printf("How are you %%dad%%");` | |
Re: If they turn off broadcasting of the SSID from the router, then only wireless connections configured with that SSID and the security passphrase (key) will 'see' the SSID. Any other wireless connection will just see something like 'Unknown network'. | |
Re: Also line 20 `else { int main() ; }` This is another function prototype, though even if you wrote: else { main(); // recursive call to main } Recursively calling main() should not be done. In function: `int area()` you may as well change it to `void area()` as you … | |
Re: bool containsVowel (string s) { if (0 == s.length()) return false; if ( (s.substr(0,1)=="a") || (s.substr(0,1)=="e") || (s.substr(0,1)=="i") || (s.substr(0,1)=="o") || (s.substr(0,1)=="u") ) return true; return containsVowel (s.substr(1, s.length() - 1)); } I'll leave you to work out handling uppercase vowels. | |
Re: Use [std::getline](http://www.cplusplus.com/reference/string/getline/), at present when you have `cin >> name`, if the entered name is M John then only M will be read into the name, for information on why your program then terminates refer to http://www.daniweb.com/software-development/cpp/threads/90228/flushing-the-input-stream | |
Re: There's most likely some memory junk in the upper 16 bits of the ebx register, so change `mov bx,1` to `mov ebx,1` | |
Re: See the comments I added to your display function. void display() { ifstream ofile("abc.txt"); string bookname; string publisher; string author; int copies; int price; int edition; // none of this will display anything from abc.txt // as nothing from abc.txt has been read. cout<<" Book Name: "<<bookname<<endl; cout<<" Publisher Name: … | |
Re: long int - 4 bytes char/unsigned char - 1 byte float - 4 bytes double - 8 bytes The same for x64. | |
Re: The simple reason for the error is that the scope in which BankAccount b1 is valid, ends with the closure of your `if (input == "y")` block. Here's your code with a few minor alterations. class BankAccount { protected: double balance; public: BankAccount() { balance = 0.0; } BankAccount(double b) … | |
Re: You could also handle invalid input like this: unsigned short int x; bool flag = false; cout << "Enter an integer that I will reverse i.e. 301 --> 103" << endl; while (!flag) { cin >> x; if (cin.fail() ) { // clear error flags and flush input cin.clear(); cin.ignore(90, … | |
Re: > Not possible. Line 27 is wrong, as I explained in my last post. open() doesn't take a std::string as the first argument, it takes only char*. This was discussed in [this thread](http://www.daniweb.com/software-development/cpp/threads/442092/stdstring-as-argument-to-ifstream.open-). and is possible, though I can't vouch for every compiler accepting a std::string as the file name. … | |
Re: You're variables are being filled in the scope of `main()`, so once you call `output()` those variables are no longer in scope. The 'dirty' solution would be to declare the variables as global variables. A cleaner way would be to define a struct to hold the variables, fill the struct … | |
Re: Apart from mike_2000_17 suggestions, another alternative would be to use a launcher for your application. launcher.exe which doesn't rely on the possibly missing dll, checks for the dll and if not found issues the error message and exits, otherwise it launches the main executable. You could even embed the main … | |
Re: > The second pow function has no exponent. I thought this at first, but if you look closer you'll realise that it does. On line 42. `a = sqrt(x);` What is the purpose of a and where should it be used? (line 43?) | |
Re: Something like this? struct person { string first; string last; string addr; string phone; }; int main () { vector<person> pvec; person tp; tp.first = "Rhino"; tp.last = "Neil"; tp.addr = "22 Acacia Avenue"; tp.phone = "5554646"; pvec.push_back(tp); tp.first = "Orson"; tp.last = "Cart"; tp.addr = "Some Place, Unknown"; tp.phone … | |
Re: Here's a fairly memory efficient example. The idea is basically to create an array where each bit in the array represents an integer. If the bit representing that integer is set then the function returns false, otherwise it sets the corresponding bit and returns true. bool add2intArray(unsigned int* iarray, int … | |
Re: Number of integers = max_num - min_num + 1; // = 4 // 1/2 * 4 * (2 + 5) = 14 | |
![]() | Re: The name strings should be "Jon" and "Bill" so I'm surprised it compiles. Without knowing anything about your classes, it's difficult to comment further. ![]() |
Re: > The function returns true if the HEAP property holds among the array elements x[i]...x[n-1] , and false otherwise. The HEAP property is simply that for every value of j between i and n-1 , x[j] is not less than its heap children **if they exist**. (The heap children of … | |
Re: In class Tree you have a constructor defined but no implementation for it. class TREE { public: NODE * headLeaf; NODE * getmin(); void Binary(NODE *); void Create(); void Insert(unsigned char); void printTree(NODE * n); TREE(); // <-- constructor with no implementation edit: deceptikon beat me to it. :) | |
Re: In line 65 you've got `return main()`, that's part of the problem. You should never recursively call the entry point of a program. The do/while loop should look like: do { // calculate compchoice // cin >> choice // process data } while (winCount < 3); After that you'd display … | |
Re: The major reason that your tableAverage function fails is because the average is being calculated inside the loop that iterates through the array. while (count < num) { sum += a[count]; ++count; average=sum/num; // this should not be inside the loop } You also declare `float average` when infact you … | |
Re: Set the PlainText property to false, then `RichEd.Lines.SaveToFile('...\blah.rtf');` or use a TMemoryStream not a TStringStream. | |
Re: Try calling [UpdateWindow](http://msdn.microsoft.com/en-us/library/windows/desktop/dd145167%28v=vs.85%29.aspx) after you call .put_Text("Waiting...") | |
Re: You've got: memcpy(InBuffer,"KL10",4); memcpy(&InBuffer[4],"123456",6); memcpy(InBuffer[10],"0987",4); Do you see the error in line 3? | |
Re: `(*string <= '9' && *string >= '0')` In hexadecimal this translates to *string <= 0x39 && *string >= 0x30 `*string - '0'` Assume the number is 8, therefore *string would be in hex 0x38. So 0x38 - 0x30 = 8 You could also use: `value = (value * 10) + … | |
Re: Read this - http://www.daniweb.com/software-development/cpp/threads/78223/read-this-before-posting-a-question Then give coding the program your best effort. | |
Re: void getTopTwoScores(double scores[], int numScores, double& highest, double& secondHighest) { if (numScores == 1) { highest = secondHighest = scores[0]; // nothing else to do return; } // initialize highest and secondHighest // assume highest is scores[0] // secondHighest we'll set to negative maximum double value highest = scores[0]; secondHighest … | |
Re: > I have got an integer as 0010000001 Is 0010000001 binary? If it is, just shift right the number of digits to remove. If it's just a decimal integer then num/10000 seems logical. | |
Re: `find 2 ^ k` Seeing as you can't use the pow(...) function, you could just use bit shifts. 2 << (k - 1) 2 shift left (k -1 ) will give you 2 to the power of k, where k is an unsigned whole number. | |
Re: I really don't have the time at present to go through all your code. One thing that immediately stands out is: private: Node *attachedNodes[4]; Your code is using attachedNodes[0] .. attachedNodes[4] inclusive, which equals 5 Nodes not 4. | |
Re: I'm not sure whether this is what you're after: #include<iostream> #include <iomanip> //#include<fstream> using namespace std; int main() { int input = 1; int board[3][4]; for(int i=0; i<3; i++) //This loops on the rows. { for(int j=0; j<4; j++) //This loops on the columns { board[i][j] = input; input++; } … | |
Re: Here's some code for your 3rd function. void aretheysame(int x, int y, int z) { if (x == y && y == z) { cout << "All numbers equal" << endl << endl; return; } if (x != y && y != z && x != z) { cout << … | |
Re: You have a function declaration of `char getServiceCode (char serviceCode);` that you try to pass your char serviceCode variable to. You need to either pass the variable instance or a pointer to the variable, otherwise nothing will be assigned from the function to the serviceCode address space. Just change your … | |
Re: Childish rubbish that's not worth discussing. Read the forum rules http://www.daniweb.com/community/rules | |
Re: It all looks fine to me too, just a few things to clean up: *Close the file when you're finished with it - `in.close();` *Pause execution to read the string ( cin.get() or similar) and then `return 0;` | |
Re: Try changing the following - line 3: int again='y'; line 14: again = getch(); | |
Re: Perhaps CreateTimerQueue, CreateTimerQueueTimer, DeleteTimerQueueTimer would do what you want. Plus it's easy to wrap them into a class. http://msdn.microsoft.com/en-us/library/windows/desktop/ms682483%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/windows/desktop/ms687003%28v=vs.85%29.aspx | |
Re: > what I should write beside return ? Use cout to inform you what max is. Pause execution before `return 0;` so that you can see the result. After that, look at ways to optimize your maxValue function. | |
Re: Initialize WNDCLASS as already suggested and after your call to ShowWindow(...), call UpdateWindow(hWnd); | |
Re: > Can I get the question's solution? No, you won't receive any help until such time as you present code that demonstrates that you've made a genuine attempt to solve the problem. |
The End.