1,174 Posted Topics

Member Avatar for sexyzebra19

[code] int main() { Matrix A(2, 3); Matrix B(3); return 0; } [/code] >> Then does this create 2 separate matrices stored in data_? Yes it does. You have two distinct objects of type Matrix, they both withhold their own vector, so there is no interference between the two objects. …

Member Avatar for Fbody
0
125
Member Avatar for kangarooblood

[QUOTE=kangarooblood;1138635]well i do not want to use the system syntax, isn't there any other way to open a program in c++?[/QUOTE] No there isn't. You have to resort to OS specific functions to start programs.

Member Avatar for Ancient Dragon
0
115
Member Avatar for igodspeed

It seems that the code uses [ICODE]getrusage()[/ICODE], which is not available on Windows. You can use [URL="http://msdn.microsoft.com/en-us/library/ms683223(VS.85).aspx"]GetProcessTimes()[/URL] on Windows. [QUOTE] actually it compiles if i change a few things but there are many linker errors. Could someonline please tell me where the problem is at [/QUOTE] You could have been …

Member Avatar for mitrmkar
0
247
Member Avatar for wilsonz91

It appears as if [code] total [COLOR="Red"]+=[/COLOR] weightcount(weight) + distancecount(distance); [/code] would do it. And also initialize [ICODE]total [/ICODE]to zero before entering the loop.

Member Avatar for wilsonz91
0
184
Member Avatar for johndoe444

Are you sure you posted a relevant code snippet? The error message says: error: no matching function for call to ‘[B]merge[/B](vertex*&, int&, int&, int&) So there should be a call to [ICODE]merge(...)[/ICODE], but there isn't.

Member Avatar for mitrmkar
0
250
Member Avatar for wendell_

[code] Area::Area( int y, int x ) { for ( int i = 0; i != y*x; ++i ) { [COLOR="Red"] // the compiler sees the below line as a function declaration, // 't' is a function that takes no arguments and returns a Tile. [/COLOR] Tile t(); area_tiles.push_back(t); } …

Member Avatar for mitrmkar
1
116
Member Avatar for Anarionist

[QUOTE=Anarionist;1138106]would it affect the program any?[/QUOTE] Could you provide an example or two regarding the changes you mean?

Member Avatar for mitrmkar
0
92
Member Avatar for asm2hex

[code] // First you have to do this for(for_loop_conditions) { free(charArray[i]); } // ... and then also this free(charArray); [/code] So there has to be a matching [ICODE]free()[/ICODE] for each [ICODE]malloc()[/ICODE] that you do. PS. Just to be clear ... if [ICODE]charArray[/ICODE] is also dynamically allocated, it needs to be …

Member Avatar for mitrmkar
0
80
Member Avatar for Suicidal_tool

Adding a note ... you are doing some out-of-bounds access there, for example [code] // two 'coord' objects, meaning // that you only can access indexes 0 and 1, nothing else. coord asteroid[2]; ... //Collision check for(int i = 0; i< 2; i++) { asteroid[i].collision(asteroid[i+1]); } [/code]

Member Avatar for mitrmkar
0
174
Member Avatar for frag

I posteed but it appeared that it didn't 'notice' my post You are hijacking frag's thread, start your own threads.so the problem with this one is that i get error like this in Visual C++ :: Run-Time Check Failure #2 - Stack around the variable 's' was corrupted. what should …

Member Avatar for vmanes
0
93
Member Avatar for cool1_best1

[QUOTE=jbragadeesh;1137302]I have done the same in Java [URL="http://www.technicalypto.com/2010/02/stack-using-linked-lists-in-java.html"]http://www.technicalypto.com/2010/02/stack-using-linked-lists-in-java.html[/URL][/QUOTE] Good for you, but please don't resurrect an old C++ thread just for the sake of saying that you've done something similar in Java, thank you.

Member Avatar for mitrmkar
0
155
Member Avatar for newcuser

I think you are just 'moving too fast'. Study the documentation, for example [URL="http://msdn.microsoft.com/en-us/library/z5hh6ee9(VS.80).aspx"]fopen_s()[/URL].

Member Avatar for mitrmkar
0
405
Member Avatar for techie929

[QUOTE=techie929;1137237]//Here is the function of inserting nodes.I tried using strcmp but its still not working. [/QUOTE] What do you mean by "still not working"? Do you really want to use [ICODE]exit()[/ICODE] there? I.e. your program gets terminated when duplicate data is encountered. A suggestion regarding initialization of a [ICODE]tree_node[/ICODE] [code] …

Member Avatar for mitrmkar
0
106
Member Avatar for caribedude

Something that looks suspicious ... [code] TitleState::~TitleState() { isCurrentState=false; StartButton.OnCleanup(); SDL_FreeSurface(background); } //------------------------------------------------------------------------------ void TitleState::OnExit() { StartButton.OnCleanup(); isCurrentState=false; SDL_FreeSurface(background); } [/code] I'd say that be sure that you don't free anything twice i.e. don't do [ICODE]SDL_FreeSurface(background)[/ICODE], if the 'background' has already been freed. Then change [code] void Out(char* words) { …

Member Avatar for caribedude
0
252
Member Avatar for suncica2222

[QUOTE=suncica2222;1135944] what is this (_CreateProcess) in the code??? is this a cast types?[/QUOTE] Yes it is a type cast. Why would you want be doing that kind of thing? You can simply call [ICODE]CreateProcess(...)[/ICODE] with the arguments it takes, without hassling with function pointers at all.

Member Avatar for WaltP
0
91
Member Avatar for kavourdoukos

>> But i get error on push_back() while compiling. The [ICODE]alfadia[/ICODE] vector stores objects of type [ICODE]alfa[/ICODE], not pointers to such objects. Then again [ICODE]new alfa[/ICODE] returns a pointer to the allocated [ICODE]alfa[/ICODE] object. So, if you want to store objects ... [code] // vector for storing objects ... vector<alfa> …

Member Avatar for mitrmkar
0
97
Member Avatar for damndamn

[QUOTE=damndamn;1136544]can u give me the codes... :([/QUOTE] This assignment has been discussed [URL="http://www.daniweb.com/forums/post1135712.html#post1135712"]before[/URL]

Member Avatar for peter_budo
-3
185
Member Avatar for 140chris140

You probably want to start a new VS project that aims to build a library and add your work this far to that project. The very basic (simplified) scenario goes something like this ... The output of the project will be a library file (.lib) and optionally a [I]dynamic link[/I] …

Member Avatar for 140chris140
0
533
Member Avatar for intervade

Return a reference to the stream object, that's the way it has been designed to be done (the compiler complains about the streams copy constructor), so [code] ostream & operator<<(ostream &out, LinkedList list) { list.display(out); return out; [/code] Then furthermore, basically you want to pass class/struct objects by reference (or …

Member Avatar for mitrmkar
0
153
Member Avatar for valeriy_zf

[QUOTE] Something is wrong with "dear_son"[/QUOTE] Yes, you do have room there for 5 children [code] dear_son = gcnew array<my_child^>(5); [/code] but they need also be given birth first, so [code] F.dear_son[0] = gcnew my_child; F.dear_son[0]->mas_1D[1] = 23; [/code] So there were no objects yet, only handles to such, hence …

Member Avatar for valeriy_zf
0
152
Member Avatar for wwsoft

[QUOTE=wwsoft;1135933]how do you create one ? Im trying to sort objects by their z[/QUOTE] You might have something as simple as [code] // Compares two game objects by 'z' bool game_obj_compare(const game_obj * lhs, const game_obj * rhs) { return lhs->z < rhs->z; } // To sort a vector of …

Member Avatar for mitrmkar
0
104
Member Avatar for Aliun

I think that there is no protection against adding a ship several times to same location (neither for the user nor the computer). Then are you sure that you have gotten the usage of [ICODE]rand()[/ICODE] right, i.e. what does [ICODE](rand()%8)-1; [/ICODE] do? Then try to type in some unexpected input …

Member Avatar for Aliun
0
999
Member Avatar for martin_dore

Sorry but the code you've posted is somewhat vague/insufficient. By looking at it, even the >> povbGarniture -> bInserer ((char) szTampon [n]); should fail. Are you sure that you posted portion of the header file that you are actually using (note that the class declaration is missing the ending brace)? …

Member Avatar for martin_dore
0
108
Member Avatar for free2rhyme2k
Member Avatar for nerdinator

The [ICODE]<string>[/ICODE] header provides a global [URL="http://www.cplusplus.com/reference/string/getline/"]getline()[/URL] that does what you need i.e. it works with [ICODE]std::string[/ICODE]. For example [code] #include <string> #include <fstream> #include <iostream> int main() { std::ifstream ifs("file.txt"); std::string s; while(getline(ifs, s)) { std::cout << s << std::endl; } return 0; } [/code]

Member Avatar for nerdinator
0
74
Member Avatar for tomtetlaw

>> I've looked around in my code, and I can't find any variables that have been assigned that address(0xccccccd0). In MS VS debug builds, if you don't explicitly initialize a pointer that is on the stack, it gets initialized with the value 0xcccccc[B]cc[/B]. So make sure you don't use uninitialized …

Member Avatar for mitrmkar
0
128
Member Avatar for iamcreasy

[QUOTE=iamcreasy;1133642]But it is printing the last line twice. [CODE] while(cin) { getline(cin, str); s_v.push_back(str); } [/CODE] [/QUOTE] The condition you have in the [ICODE]while()[/ICODE] is not working. Instead you have to .. [code] while(getline(cin, str)) { s_v.push_back(str); } [/code] >> also, i wanna get ride of this line [ICODE]freopen("in.txt", "r", …

Member Avatar for WaltP
0
131
Member Avatar for mmasny

[QUOTE=mmasny;1133723]How is it possible that my program asked to cout a bool variable writes 104 on the display? Even if the variable wasn't initialized, it should display 0 or 1 I thought?[/QUOTE] Well, you thought wrong there. Don't assume anything about [I]uninitialized variables[/I] and their possible values at any given …

Member Avatar for mitrmkar
0
198
Member Avatar for ilyaz

>> Why is it creating the empty file? I'd suggest debugging the program and try to see where it fails and why. You could use [URL="http://msdn.microsoft.com/en-us/library/14h5k7ff.aspx"]_stat()[/URL] to check both the file's existence and its size in one go.

Member Avatar for ilyaz
0
201
Member Avatar for lashatt2

Maybe the following takes you a step further ... [code] // Note that you have to get the following window handle ('edit') // somewhere. If you use an uninitialized handle like below, // then GetWindowText() fails. HWND edit; char t[MAX_PATH]; char query[MAX_PATH]; // Try to get the window text if( …

Member Avatar for mitrmkar
0
99
Member Avatar for suncica2222

[QUOTE=suncica2222;1131522]so is this method convenient for long time pauses like 2-3 days? because tstart needs to be large number?[/QUOTE] In terms of being sufficient, the [ICODE]time_t[/ICODE] data type is OK. Check out how many bits your [ICODE]time_t[/ICODE] actually is, (probably 64). Then again, this is the same construct that you …

Member Avatar for suncica2222
0
149
Member Avatar for newcuser

[QUOTE=newcuser;1131090]Here is what I have so far. Suggestions?? [/QUOTE] Compile the code and start working through the errors/warnings from top to down. Once you think you have solved/fixed a specific error, re-compile and see the results, i.e. don't try to fix all errors at once.

Member Avatar for mitrmkar
0
183
Member Avatar for wwsoft

Use the [ICODE]extern[/ICODE] keyword to introduce the [I]variables[/I] inside the header (.h) files. [I]Define[/I] these [I]variables[/I] in their counterpart .cpp files. For example, your header could be [CODE] #ifndef OBJECT_H_DEFINED #define OBJECT_H_DEFINED // file: object.h // std::vector is needed in this header file #include <vector> // Introduce what is exposed …

Member Avatar for wwsoft
0
145
Member Avatar for katwalatapan

[QUOTE=katwalatapan;1131617]I tried to call memcpy twice but it stored the 1st copy of 4 seconds correctly but not the other copy. I was assuming that once data is copied in the buffer, its memory address automatically points to the next memory block[/QUOTE] The pointers don't automatically 'adjust' themselves, no matter …

Member Avatar for katwalatapan
0
185
Member Avatar for arafat_alam

[QUOTE=arafat_alam;1131604]i am facing problems of destructor in the following code.destructor is not working[/QUOTE] The memory allocation is one byte off, you need to allocate an additional byte for the [I]null terminator[/I] placed there by [ICODE]strcpy()[/ICODE], so [code] len = strlen(str) + 1; [/code] FYI, [ICODE]sizeof(char)[/ICODE] is always one (1), so …

Member Avatar for arafat_alam
0
132
Member Avatar for tetron

[QUOTE=tetron;1131335] I tried to move the entire visio contents: /VC/bin/ to the same folder[/QUOTE] I suppose you mean Visual Studio instead of 'visio', right? Anyway, consider that upon install, the VS tools do modify the system by modifying environment variables (and being MS tools, maybe system registry etc.) in order …

Member Avatar for mitrmkar
0
522
Member Avatar for adel_elrefaey

I'd suggest that you post this question on Microsoft's dedicated [URL="http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/threads"]Visual C++ General[/URL] forum. They probably know the answer to this one more or less off-the-shelf.

Member Avatar for adel_elrefaey
0
118
Member Avatar for Suicidal_tool

Are these [ICODE]getxx[/ICODE] and [ICODE]getyy[/ICODE] member variables or perhaps functions? If the latter, then you need [code] if(asteroid1.getxx() == asteroid2.getxx() && asteroid1.getyy() == asteroid2.getyy()) { cout<<endl; cout<<"Collision"<<endl; } [/code] >> if i was to move this and just make a comparason function, could i send the object and its elements …

Member Avatar for Suicidal_tool
0
97
Member Avatar for Jiwe

[QUOTE=Jiwe;1130688]It's part of the windows.h library I think?[/QUOTE] Yes it is, but you need to be sure that you link with Advapi32.lib.

Member Avatar for Jiwe
0
3K
Member Avatar for rmrgrs

>>the prototype is in the header file... That is not enough, you cannot leave the functions' return type out of the function definitions. Then you use the comma operator along with a return statement, that is plain wrong. Though it compiles, only the latter value is returned. [code] // Decide …

Member Avatar for rmrgrs
0
84
Member Avatar for mikabark

>> Use std::copy. If not then create your own. Additionally a simple alternative is [code] vector<string> src; vector<string> dest; src.push_back("abc"); src.push_back("def"); src.push_back("ghi"); // make an exact copy of src, resizing dest dest = src; [/code]

Member Avatar for mikabark
0
151
Member Avatar for Dewey1040

>> I want to use gcount but I cant figure out the correct formatting. Since you are having two [ICODE]string[/ICODE]s there, you can get a string's length using e.g. [ICODE].length()[/ICODE] I.e. [code] string test = "abc"; // the following would print 3 cout << test.length() << endl; [/code] But then …

Member Avatar for WaltP
0
178
Member Avatar for invisi

[QUOTE=invisi;1129738]But why didn't it work last time it gave me two errors (shame I'll probably never know) :([/QUOTE] It would have been better to have posted the actual error messages (as given by the compiler) along with the code that wasn't compiling. Otherwise people here can only guess what might …

Member Avatar for invisi
0
100
Member Avatar for hax-

[QUOTE=hax-;1129338] I just need to know how I might go about loading up a dialog that I have created in my .rc (that is, getting it to pop up when I click a button)[/QUOTE] You are doing that very thing already, i.e. using DialogBox(...). So, - define a new dialog …

Member Avatar for mitrmkar
0
141
Member Avatar for 0xe9

You might want to take a look at [URL="http://msdn.microsoft.com/en-us/library/ms686016(VS.85).aspx"]SetConsoleCtrlHandler()[/URL]

Member Avatar for mitrmkar
0
64
Member Avatar for swolll

Why are you doing a thing like [ICODE]listSongs.push_back(NULL);[/ICODE] there? Are you sure that you are not doing e.g. a [ICODE]listSongs.at( [I]index of a NULL pointer[/I] )->getSongName()[/ICODE] causing the seg fault?

Member Avatar for swolll
0
257
Member Avatar for spetsnaz26

The fix is simple, [code] // a1 comes with 10 elements -> // a2 also comes with 10 elements (at minimum) a2=new abc[ 10 ]; [/code] So, you were simply trashing memory. What was the main idea of doing the a2 allocation like you did? Were you just trying out …

Member Avatar for spetsnaz26
0
1K
Member Avatar for Stefano Mtangoo

>>what is ULONG equivalent of C++ or it is just ULONG? It is typedefed via <windows.h>, and is documented in [URL="http://msdn.microsoft.com/en-us/library/aa383751(VS.85).aspx"]Windows Data Types[/URL] That's a good page to lookup the data types and #defines used by Windows. >>GetLastError()); //So GetLastError retuns a sring or char*? No, see [URL="http://msdn.microsoft.com/en-us/library/ms679360(VS.85).aspx"]GetLastError Function[/URL]. In …

Member Avatar for Stefano Mtangoo
0
2K
Member Avatar for nats01282

[QUOTE=nats01282;1128274]how do i make a infinate loop? [/QUOTE] For example [code] for ( ; ; ) { // your code here } // or ... while( true ) { // your code here } [/code]

Member Avatar for VilePlecenta
0
1K
Member Avatar for suncica2222

[QUOTE=suncica2222;1128057] tell me which is equivalent function with TCHAR for wcscpy(),for copying strings,and the others I will find in google?[/QUOTE] Forget the Google, instead look up the particular function in MSDN, for example [URL="http://msdn.microsoft.com/en-us/library/kk6xf663.aspx"]wcscpy()[/URL]. Then, on that page scroll down to where you see "TCHAR.H routine", there you'll find the …

Member Avatar for Salem
0
171

The End.