921 Posted Topics
Re: If you have to implement your own algorithm to do this, try taking a look at a snippet I made some time ago. [B][URL="http://www.daniweb.com/code/snippet1068.html"]Link[/URL][/B] But otherwise, this is an easy problem, you could even try [ICODE]std::stringstream[/ICODE]. You practically don't have to do anything :icon_lol: [CODE=CPLUSPLUS]#include <iostream> #include <sstream> #include <string> … | |
Re: Creating your own [B]strcat[/B] is nothing, it takes literally a couple of lines.[CODE=CPLUSPLUS]void my_strcat(char *dest, char *source) { // Find null-terminator while ( *++dest ); // Add new string while ( *dest++ = *source++ ); }[/CODE]Making it safe would be the next problem. But think about what [B]Lerner[/B] is telling … | |
Re: >plz help its urgent... Not for us. >i actually want to read the raw file(CR2 file) of jpeg image using turbo C... You shouldn't be using Turbo C in the first place, you should get yourself a decent compiler. You may be able to read the jpeg file using windows … | |
Re: Just write your own loop to copy chars without the null-terminator? However, on this line:[CODE]m_length = [COLOR="Red"][B]strlen[/B][/COLOR](m_buffer) + [COLOR="Red"][B]strlen[/B][/COLOR](other) + 1;[/CODE]You are using a function which relies on the null-terminator at the end of the string, so you will have to keep track of the string length yourself while adding … | |
Re: In future, post using code-tags, show what errors you're having, and give more detail to your problem. Just to get some sort of idea on indentation, I've formatted the code for you.[CODE=CPLUSPLUS]#include <iostream> #include <fstream> using namespace std; void namefile(ifstream & infile); void openfile(ifstream & infile); void displayScores(int scores); void … | |
Re: Perhaps be more specific... what exactly is it that you want to know? | |
Re: > The problem is -- how will you know which one is the browser? Simple :) You can use Spy++ to find out the browsers class name and then you can narrow down which windows are browsers. I found out these: [CODE] Firefox's Class: MozillaUIWindowClass IExplorer Class: IEFrame [/CODE] Now … | |
Re: Why are you using the preprocessor for this? This compiles and works for me:[CODE=CPLUSPLUS]#include <iostream> using namespace std; struct A1 { static const int _AINT = 0; }; struct A2 { static const int _AINT = 1; }; template< class T > struct B{ void Fun(){ if ( T::_AINT == … | |
Re: >i try this program, but something wrong with the loop function. How unfortunate... you may get more help if you post what you've done up to this point. | |
Re: Would you mind posting some more code? It can only make it easier to understand what's causing the problem. | |
Re: In future, remember to use [URL="http://www.daniweb.com/forums/announcement8-3.html"]code tags[/URL]. Here is the code how I would have formatted it, after cleaning it up a little for you.[CODE=CPLUSPLUS]#include <stdio.h> int main() { int x; printf("Enter an integer:\n"); scanf("%d", &x); if ( !((x <= 20) && (x > 0)) ) { printf("\nYou have entered … | |
Re: I've had it before, but ever since I formatted my pc, the problem seems to have gone. I've always used firefox. | |
I came across a small bug recently when clicking on a link to a user profile. It seems that no matter what name you click on, it will only ever link you to the member who last posted in that thread. In my screenshots, I clicked on the link to … | |
Re: I remember having that problem, I accidently set the snippet programming language to [B]CPP[/B] instead of [B]CPLUSPLUS[/B] which showed up in its own catagory. Seems to have been fixed now, but it would have been nice to be able to edit that at the time :-/ | |
Re: Hmm, an example of a memory leak.[CODE=CPLUSPLUS]int main() { int **a = new int*[10]; for (int i = 0; i < 10; ++i) a[i] = new int[5]; /* Do stuff with a */ for (int i = 0; i < 10; ++i) delete[] a[i]; }[/CODE]In this example, you freed the … | |
Re: If your new to C++, you should start on something much easier. I don't even know how to do this, but I can guess it involves some pretty complex stuff, so I don't think you're going to get this done unless someone literally gives you the entire code. | |
Re: Isn't there a checkbox on that dialog somewhere that says "Do not show this warning again", or something along those lines? If it's there, try pressing it :icon_confused: | |
Re: The problem is easy to solve, instead of adding a new line to the text box, simply add the line to a global string, then assign the string to the textbox.[CODE=CPLUSPLUS]#include <windows.h> #include <iostream> HWND hEdit; // Text Box std::string log; void AddLogLine(char *line) { log += line; log += … | |
Re: It's all [URL="http://www.winprog.org/tutorial/"]here[/URL]. | |
Re: Either change the style of the window, or add this to your windows procedure:[CODE=CPLUSPLUS]case WM_GETMINMAXINFO: { MINMAXINFO *mmi = (MINMAXINFO*) lParam; mmi->ptMinTrackSize.x = mmi->ptMaxTrackSize.x = 500; // Width mmi->ptMinTrackSize.y = mmi->ptMaxTrackSize.y = 500; // Height } break;[/CODE]Hope this helps. | |
Re: [URL="http://www.daniweb.com/forums/thread174301.html"]http://www.daniweb.com/forums/thread174301.html[/URL] | |
Re: >what is advantages of main() function. Without it, there wouldn't be a program. [URL="http://wwwx.cs.unc.edu/~sparkst/howto/cpp_main.php"]http://wwwx.cs.unc.edu/~sparkst/howto/cpp_main.php[/URL] | |
Re: I really don't see why this has to be so hard. Just loop through each character, find the start and end of each word, then increment the word count. I guess this is the general idea of what you want:[CODE=CPLUSPLUS]int wordCount(char *text) { int count = 0; for (int i … | |
Re: This question has been asked many times. There's a few ways to do this, an easy way is to simply fill up the array with unique integers, then shuffle it like this:[CODE=CPLUSPLUS]#include <stdio.h> int main() { int arr[10]; int i; for (i = 0; i < 10; ++i) arr[i] = … | |
Re: Or, if you're willing to spend a little, it's definitely worth buying yourself a decent book on C++. [URL="http://www.daniweb.com/forums/thread70096.html"]See this thread[/URL]. | |
Re: [B]mouse_event[/B] is used to emulate mouse events, not to detect them. If you want to be able to detect mouse clicks anywhere (even if your window doesn't have focus), you will have to use something like windows hooks. If your using the Windows API and just want to be able … | |
![]() | |
Re: If you're using windows, here's a pretty straightforward solution to retrieving the console buffer size.[CODE=CPLUSPLUS]#include <windows.h> #include <iostream> int main() { CONSOLE_SCREEN_BUFFER_INFO csbi; int ret = GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &csbi ); if ( ret ) { std::cout << "Console Buffer Width: " << csbi.dwSize.X << std::endl; std::cout << "Console … | |
Re: ... music is my life :* ^ Is new to daniweb < Wants to go iceskating... v Is hungry? :) | |
Re: >Some people might remember [B]Might[/B] remember?! you got me hooked on those games for weeks :icon_eek: And, a nice story :icon_surprised: Took a while to read though. | |
Re: Please use [URL="http://www.daniweb.com/forums/announcement8-3.html"]code-tags[/URL]. | |
Re: To make things simpler, you can read the data in as a 1D array (pointer), but still be able to access the data through a 2D array. Like this:[CODE=CPLUSPLUS]#include <iostream> #include <fstream> #include <string> using namespace std; int main() { //number of rows and cols string words[4][4]; // Pointer to … | |
Re: Could that question be any more vague? You're going to have to post much more detail before you can expect a reply of any help. | |
Re: Hey David A. Newbie, use [URL="http://www.daniweb.com/forums/announcement8-3.html"]code-tags[/URL] in future. | |
Re: I use VS2005, and I prefer it out of all the compilers that I've use in the past. | |
Re: It's an easy problem, just remember to split it up into parts. >The program should ask the user how much the pallet weights by itself First, make a program.[CODE=CPLUSPLUS]#include <iostream> int main() { }[/CODE] Now, allow the user to input the weight of the pallet.[CODE=CPLUSPLUS]#include <iostream> int main() { float … | |
Re: A portable way to retrieve the file size :icon_razz: [CODE=CPLUSPLUS]// Returns number of bytes in a file int GetFileSize(char *file) { // Open file std::ifstream f(file, std::ios_base::binary | std::ios_base::in); // Make sure it's opened correctly if ( !f.good() || f.eof() || !f.is_open() ) { return 0; } // Beginning of … | |
Re: >I have already write something! If you have some code, then post it so we can help. | |
Re: I think the author goes a little far with the '[B]beating your kids[/B]' part, but as Ancient Dragon said, a spank isn't too bad. Even though I obviously don't have kids yet... sometimes I think it's just the best solution to showing them that you're serious :icon_rolleyes: Especially after watching … | |
Re: [QUOTE=Narue;506452]>The most efficient way for swapping whole numbers is <snip xor swap> >because xor is an assembly level instruction and its much faster than any move operation. An empirical test disproves your claim. The swap using a temporary is noticeably faster on at least one compiler (Microsoft C++) given any … | |
Re: In VS2005, right-click on the toolbox, click on the menu item 'Choose Items', go to the tab 'COM Components', and check the 'Windows Media Player' check box. You can then drag that control into your form application. You will need to use google to figure out how to use this … | |
Re: I would probably try and solve this by reading all the data into an array of chars, and then manually splitting up the text. You should have more control over whats happening if you do this. See my [URL="http://www.daniweb.com/code/snippet1068.html"]code snippet[/URL]. As for converting to an [B]int[/B], it's no big task, … |
The End.