1,174 Posted Topics
Re: Maybe this will do ... [ICODE]RedrawWindow(hConsoleWnd, 0, 0, RDW_INVALIDATE);[/ICODE] [ICODE]hConsoleWnd[/ICODE] is the console's window handle. | |
Re: This is a modified version of niek_e's code [code] #include <iostream> #include <fstream> #include <string> #include <sstream> using namespace std; int main() { ifstream in; in.open("c:\\yourfile.txt"); if (!in.is_open()) { cout << "Can't open file\n"; return 1; } string line; // read one line at a time while (getline(in, line)) { … | |
Re: [QUOTE=hemendra.jadaun;632654]can anybody solve this problem.. Linking... gdtopng.obj : error LNK2001: unresolved external symbol __imp__gdImageDestroy@4 gdtopng.obj : error LNK2001: unresolved external symbol __imp__gdImageCreateFromGd@4 Debug/gdtopng.exe : fatal error LNK1120: 2 unresolved externals Error executing link.exe. gdtopng.exe - 3 error(s), 0 warning(s)[/QUOTE] Try linking with bgd.lib. | |
Re: [QUOTE=Superfat;632221]I tried it, and recieved an error, [code] [Linker error] undefined reference to `WinMain@16'[/code][/QUOTE] You are trying to build a Win 32 GUI program and you have no WinMain(...) - hence the error. If you want to build a GUI program, then write the WinMain(...) too, see [url]http://msdn.microsoft.com/en-us/library/ms633559.aspx[/url] Otherwise, start … | |
Re: How about adding a new member function, say SetStats(), which takes the user's choice and initializes a default constructed Character, i.e. [code] // default constructed Character player; cout <<"\n\nBefore we begin, please select your class." <<"\nEnter a 'W' for Warrior or an 'M' for Mage. "; char classChoice; cin >> … | |
Re: [QUOTE=Sniperx;631847]it doesnt move through.. i does the same as my first one, just displaying only the second name now[/QUOTE] To loop through all the 12 names, you can use ... [code] for(int ii = [B][COLOR="Red"]0[/COLOR][/B]; ii < sizeof(names)/sizeof(names[0]); ++ii) { cout << "player: " << names[ii] << endl; } [/code] … | |
Re: Try changing '\r' to '\n' i.e. [code] send("telnet 192.168.3.100[B][COLOR="Green"]\n[/COLOR][/B]", 150); [/code] | |
Re: [QUOTE=kux;631274]What i want to do is write some of the rows of a report style CListCtrl with a color and other rows with another color, but if I switch the color with SetTextColor the color of the text in the entire control switches, i want it to switch just for … | |
Re: Post the complete code you have. If it is large, zip it and attach the zipped file. | |
Re: [QUOTE=zoner7;630743]What in the world does line 20 do?[/QUOTE] A tutorial on it ... [url]http://www.cprogramming.com/tutorial/initialization-lists-c++.html[/url] | |
Re: A .PDF reader / outperforms Adobe's Reader big time (free) Foxit Reader [url]www.foxitsoftware.com[/url] A collection of Windows troubleshooting/monitoring tools (free) Sysinternals Suite [url]http://technet.microsoft.com/en-us/sysinternals/0e18b180-9b7a-4c49-8120-c47c5a693683.aspx[/url] | |
Re: [ICODE]a[/ICODE] gets a negative value (-1) in the following loop. [code] // checks diagonal up-right movement for(a=i-1,b=j+1;a>=0, b<N;a--,b++) { if(board[a][b]==1) { [/code] The comma operator [ICODE]a>=0[COLOR="Red"],[/COLOR] b<N[/ICODE] is not doing what you probably expect. | |
Re: [QUOTE=hacker9801;631161]If you use the new operator on a class, say [code=c++]class dummy { public: string f; }; int main(int argc, char *argv[]) { dummy *p = new dummy; return 0; }[/code] do you have to use the delete operator on [icode]p[/icode]? (since, apparently, it utilizes new.)[/QUOTE] Yes, when you want … | |
Re: [QUOTE=sambafriends;623259]Thank u very much for this, Why we are putting getchar() again If it is not what happening there please give me reason[/QUOTE] Let's say you type in one letter 'a' and press Enter, at that point, in the input buffer are [B]two[/B] characters, the letter 'a' plus the newline … | |
Re: [QUOTE=Alex Edwards;630614]I have no way to tell if there is a memory leak or not during run-time. [/QUOTE] One basic detector (covers malloc/new) can be found e.g. here [url]http://www.codeproject.com/KB/applications/visualleakdetector.aspx[/url] and google finds more ... | |
Re: [QUOTE=kux;630611]Is there any way of getting the selected date in a CDateTimeCtrl in a CString or char* or anyting?[/QUOTE] Here is one way .. [code] CTime time; if (GDT_VALID == DateTimeCtrl.GetTime(time)) { CString strDate = time.Format("%d.%m.%Y"); } [/code] See the CTime::Format(...) for more information on the the formatting options | |
Re: [QUOTE=cb02061;630209] I got assertion failure error... [/QUOTE] Can you tell which ASSERT fails? | |
![]() | Re: [QUOTE=Thew;629971]I tried to delete all the struct definitions and start over. I found when I use SceneParticulation, the error will be raised. Otherwise everything goes ok. But what's wrong in this definition: [CODE] struct SceneParticulation { public: SceneParticulation(){}; ~SceneParticulation(){}; // here the program stops and fails ParticleSystem SPParticle; }; [/CODE][/QUOTE] … ![]() |
Re: You might use std::string ... [CODE] string data; string line; while (getline(indata, line)) { data += line + '\n'; } [/CODE] | |
Re: [QUOTE=Alex Edwards;628077]If I use the [] operator and return a reference, is there any way to mark that indice when a value is assigned to it? [/QUOTE] Maybe you could use a bitset for tracking the assignments. Two things I noticed: - use of realloc() would result in fewer malloc/free … | |
Re: [QUOTE=Traicey;628319]Such as.............[/QUOTE] You might post the relevant code, so we could see where it goes wrong. | |
Re: [QUOTE=TacklesMcCaw;627705]what advantage they would get from it.[/QUOTE] To avoid name (identifier) clashes. | |
Re: After a quick look into it, I suggest that you get rid of malloc() usage. You are using 'delete' on memory that has been malloc'ed - that must not happen. Then about 'delete', you only can delete something that has been allocated by 'new', consider [code] class a { public: … | |
Re: Emphasizing line #48, the [ICODE]mc[/ICODE] object is on stack (i.e. not allocated by new), so when it goes out of scope, its destructor gets called automatically. Generally you don't call destructors, those get called via delete or automatically in case of stack objects. | |
Re: Perhaps ... [CODE] double indexLowTemp() {ind=1; for (a=0;a<col;a++) {if (low<=temp[a][0]) {low=temp[a][0]; ind=a; } } [COLOR="Green"]// output low temp ... cout << low;[/COLOR] [/CODE] | |
Re: [QUOTE=007tron;627776]that smiley not meant to be there[/QUOTE] FYI, there is the 'Disable smilies in text' option below the 'Submit Reply' button ... ;) | |
Re: [QUOTE=007tron;627195]Anyone got anything?[/QUOTE] There is one 'oddity' that needs to be pointed out, namely usage of '\' as end-of-comment marker. The backslash at the end of the single line comment works as a line continuation character and hence the next line is also taken as comment. You have one instance … | |
Re: Please use code tags when posting code, see here [url]http://www.daniweb.com/forums/misc-explaincode.html[/url] | |
Re: [QUOTE=FTProtocol;627254]do you have any clue on the function lol?[/QUOTE] You might try FlashWindow() or FlashWindowEx(). | |
Re: Most probably the problems are not about security attributes but about you not using threads. Ancient Dragon made a good point above. Think what would happen if the wait call would block when you are doing it from the same thread that created the mutex in the first place (and … | |
Re: [QUOTE=henpecked1;627101] I can't for the life of me figure out the implementation of those virtuals though, nothing I put in outputs anything from main except 172, 173, 177, 181, and 185. I need to figure out how to make it see the other lines as "inputs" to those functions and … | |
Re: Two short tutorials [url]http://www.cplusplus.com/doc/tutorial/arrays.html[/url] [url]http://www.cplusplus.com/doc/tutorial/pointers.html[/url] | |
Re: Two simple examples, hopefully you'll get something figured out of those ... [code]class a { public: a(string s1, string s2){} }; class b : public a { public: // default ctor b() : a("", "") {} // ctor with 4 strings b(string as1, string as2, string bs1, string bs2) : … | |
Re: [QUOTE=sniper29;626825]when i input rows and column.... the print result are all X...[/QUOTE] I gave it a try and there is one 'X' rest being '*'. [code] // output was after userinput Airplane Seat Assignment ****** *[COLOR="Green"][B]X[/B][/COLOR]**** ****** ****** ****** ****** ****** ****** ****** ****** ****** ****** ****** [/code] I.e. the … | |
Re: [QUOTE=Cybulski;625903]Now parameter 4: it should be &adress of this string, amirite?[/QUOTE] Basically a pointer (cast to void *) to anything you want the thread routine to receive via p_pVoid argument. | |
Re: [QUOTE=tesuji;625881]The poor problem is that neither printf nor cout of M$ visual c++ is able to print out long double values![/QUOTE] Surprisingly, at some point M$ dropped support for 80 bit long double, nowadays long double and double are equivalent (64 bits) (although distinct types). | |
Re: [QUOTE=Phan;626078] anytime when I call a function, it says that the function being called does not take 0 parameters? What does this mean?[/QUOTE] It means that you simply need to supply one or more parameters to the function, depending on how that functions defined. [code] // you must pass one … | |
Re: [QUOTE=amarhp;624958]Thank you for reply... but my question is different.. my pointer is void pointer(void *) and it may be RAW data..it could be anything. but sure tht it is not string. waiting 4 reply..[/QUOTE] Like Edward already showed, you need to know the size of the memory block to copy, … | |
Re: [CODE]int myfunction(int argc, char *argv[]){ int i; for(i=0;i<argc;i++) unlink(argv[i]); } int main(){ int argc; // argc is not initialized to any value, what might be its value here ?? char **argv; // argv is not initialized to any value, what might be its value here ?? // Now you call … | |
Re: [QUOTE=Dannyo329;625133]Yeah, Thats exactly what I want, but how do you link the object files together to make a single executable program? And when I tried making the two files, and putting the code on to them, it didn't work. Thanx[/QUOTE] What compiler are you using? | |
Re: [QUOTE=n00b3;625680] I have two basic questions. 1) Why can I not include fstream and/or string headers in my gui project? 2) Why can I not instantiate variables outside of the WindowProcedure or the WinMain functions? [/QUOTE] [code] #include <windows.h> #include <iostream> #include <fstream> #include <string> #include "my.cpp" // since fstream … | |
Re: Some more corrections in [COLOR="Red"]red[/COLOR] ... [code] /*------------------------------------------------------------------ * Assignment 7: FIRST LINKED LIST ASSIGNMENT. *Worth: 50 points *Made by: Samuel Georgeo (max11) create an in-memory SERIALLY linked-list database program which displays a menu screen. -------------------------------------------------------------------*/ #include <stdio.h> #include <iostream> #include "/var2/local/include/getch.h" using namespace std ; /*----------------------------------------------------- * MAIN PROGRAM … | |
Re: Have you tried Vintage Computer Forums? [url]http://www.vintage-computer.com/vcforum/index.php[/url] | |
Re: [QUOTE=champnim;624325]I have a string of the form "abcd\"1234\"efgh". I want to extract 1234 from this string. How should I do this?[/QUOTE] You might use strtok(), see [url]http://www.cplusplus.com/reference/clibrary/cstring/strtok.html[/url] | |
Re: [QUOTE=timbo2000;625497]Im using visual studio 2005 on XP and am recieving an error in my program that looks as if the call is not matching what is in my lib. I have been doing some reading about the code generation phase of the compiler and find that I should look at … | |
Re: [QUOTE=cam9856;625182]the code is updated i just need my question answered, anyone?[/QUOTE] Assuming that "the game just shuts down" still is the question, it is best if you post the updated code, so it can be given a test ride. | |
Re: [QUOTE=SwathiSangral;625085] In the .cpp file I have declared a object to the class as: [ICODE]CSafePtr<int> myobject(int* t);[/ICODE] [/QUOTE] The compiler actually sees that as a function prototype, i.e. a function named myobject, taking an int pointer and returning CSafePtr<int>. So, you'd need to change it as stephen84s already pointed out. … | |
Re: I have to ask you, what is the following line supposed to do? [icode]HWND inputB = GetDlgItem(hWndDlg,(GetWindowText(input,NULL,NULL)));[/icode] The following will not work, 'inputB' is a window handle, not a pointer to a char array. [icode]SetWindowText(edit,(const char *)inputB);[/icode] You need ... [code] char text[SOME_SIZE] = {0}; // ... code that sets … | |
Re: About the if/else usage [code] if( array[j]==key){ search=search + 1; success= success + 1; } else if(array[j] !=key){ search=search + 1; success=success; } [/code] You can change it to [code] if( array[j]==key){ search=search + 1; success= success + 1; } else{ // here you already know that array[j] != key … | |
Re: A couple of things, get rid of the eof() in the while() loop, instead use [CODE] int format_file(string filename) { ... while (getline(readfile, line)) { ... } } [/CODE] If 'line' contains only whitespace, then the following will crash because [icode]line.length()-1[/icode] will be negative [CODE] //check for trailing spaces while … |
The End.