1,174 Posted Topics
Re: >> I'm now off to learn how to compile to dll in C++, maybe it will hook me Assuming you have some version of Visual Studio, you might go through MSDN's [URL="http://msdn.microsoft.com/en-us/library/ms235636%28VS.80%29.aspx"]Walkthrough: Creating and Using a Dynamic Link Library[/URL]. It's close to the simplest console app/dll configuration that one can … | |
Re: I think you'd rather want to use [icode]execvp()[/icode], see [URL="http://www.opengroup.org/onlinepubs/009695399/functions/exec.html"]exec()[/URL] - scroll down to [B]Using execvp()[/B], there's a minimum usage example. | |
Re: >> when I iterate through login_times, all of them have the same time value asctime() uses a single static buffer and returns a pointer to this buffer every time you call it. In other words, all pointers that you store in the [icode]login_times[/icode] array, point to the very same location … | |
Re: This very much looks like a 'trick' question of some sorts. So assuming that the requirements are that 1) the output must be zero (0) and 2) only the comment block is to be modified .. it can be done in standard C++, here's a hint, replace [code] void function(int … | |
Re: >> the compiler is about a year or 2 old. >> Its a C++/C compiler. gcc Most likely the code is not a compiled as C, but C++ instead. In C, you don't need to cast return value from malloc(), and moreover, you [URL="http://c-faq.com/malloc/mallocnocast.html"]shouldn't do that[/URL]. | |
Re: I think kes166 pointed out your problems. I'd just suggest that when you compile your programs, pass the following switches to the compiler (via Dev-C++ IDE) [icode]-Wall -Wextra -pedantic[/icode] That will enable most of the warnings and generally also warns about (some) non-standard code (like variable length arrays, which you … | |
Re: Since this is MFC, see [URL="http://msdn.microsoft.com/en-us/library/x9y44b47%28v=VS.80%29.aspx"]CComboBox::AddString()[/URL] [icode]GetDlgItem()[/icode] returns a [icode]CWnd *[/icode], meaning that you need a typecast to [icode]CComboBox *[/icode]. For example [code] CComboBox * pCombo = (CComboBox *) GetDlgItem(IDC_COMBO1); pCombo->AddString("Text"); [/code] | |
Re: [URL="http://www.cplusplus.com/reference/clibrary/cstdio/perror/"]perror()[/URL] might come in handy, so perhaps try [code] void uloz2D(char nazevsouboru[]) { // You don't need the NAZEVPR2 variable here printf("%s\n", nazevsouboru); FILE *soubor2 = fopen(nazevsouboru, "w"); if(soubor2) { fprintf(soubor2,"A"); fclose(soubor2); } else { // Failed, what's the reason? perror(nazevsouboru); } } [/code] Are you sure about your last … | |
Re: >> ...When i try to get that date back again in the Actor class >> by the code inception = dateInception.getCharacteristics(); >> I get a result that is like 123441234/1234234234/1234234. By looking at the code (your first post), this line you mention, only exists within the Actor's constructor, meaning that … | |
Re: >> dude, i'm creating win32 console application...... Ancient Dragon's suggestion will work provided that you [icode]#include <windows.h>[/icode] If you don't want to pull in the windows.h header, a more lightweight solution would be to use C run-time function [URL="http://msdn.microsoft.com/en-us/library/1z319a54%28v=VS.100%29.aspx"]_chmod()[/URL]. To use that function, you need to [icode]#include <io.h>[/icode]. | |
Re: Looks like the troubles start from line #35 onwards. You could shorten the comparison like so .. [code] bool operator() (const PdpNetworkLocalKey& lhs, const PdpNetworkLocalKey& rhs) const { if(lhs.ip == rhs.ip) // Todo: Use lhs.isLocal and rhs.isLocal here to order the items as you like return ???; else // Order … | |
Re: Assuming this is on Windows, you can load the bitmap with LoadBitmap()/LoadImage(), and then set it using the [URL="http://msdn.microsoft.com/en-us/library/bb761822%28v=VS.85%29.aspx"]BM_SETIMAGE Message[/URL]. The button needs the BS_BITMAP style bit set, but I believe your dialog editor takes care of that. | |
Re: > .. but I don't know how. I will research it and try to fix my question. The code tag instructions in the [link](http://www.daniweb.com/forums/thread78060.html) seem to be a bit out-of-sync. Here's a version which should work as of this writing ... **Use code tags!** The easiest way to do this … | |
Re: >> i tried the following statements they also give same output printf() discards the excess arguments, hence the output is identical in all the three cases. By the way, please write in full English to make it easier to understand what you are saying. [EDIT] I think your code snippet … | |
Re: >> This compiles, but it is not working. The loop condition is backwards (has [icode]![/icode]). You are complicating the reading, to read a [icode]double[/icode] at a time .. [code] ifstream myfileIN("data2.bin", ios_base::binary); double dub; // As long as sizeof(double) bytes is read .. while(myfileIN.read(reinterpret_cast<char*>(&dub), sizeof(dub)).gcount() == sizeof(dub)) { dq.push_back(dub); } … | |
Re: A suggestion, you might use [icode]stringstream[/icode] for extracting the two fields, that would work for both TAB and SPACE -separated fields. That would be along the lines of .. [code] #include <sstream> // for stringstream // Function to perform lookup in provided MAC to hostname file string search_eaddr(const string & … | |
Re: You can split a string literal to multiple lines like so .. [code] // A single string literal cout << "This program will " "add, subtract, multiply, or " "divide two numbers inputted " "by the user." << endl; [/code] | |
Re: >> I go menu->[B]settings->build settings[/B]->select gnu-g++ in the left tree->switch-> >> and change the -l to the -lmapi32 Those are general build settings, shouldn't you rather add the mapi32 library to the current project's configuration? That would be; from the menu, select Workspace / Open active project settings / Linker, … | |
Re: All the three lines of code below have [URL="http://c-faq.com/ansi/undef.html"]undefined behaviour[/URL] and are to be avoided [code] digit[curpos] = ((digit[curpos]++) % 10); p = (p++) % 10; // doesn't work x = (++x) % 10; // works [/code] See [URL="http://c-faq.com/expr/seqpoints.html"]comp.lang.c FAQ list · Question 3.8[/URL] | |
Re: > deprecated conversion from string constant to ‘char*’ The string literals are constants, so using [icode]const[/icode] is in order, like so [code] const char * months[] = {"january","february","march","april"}; [/code] | |
Re: From the VS 6 Help menu, select Keyboard Map and then Edit instead of 'bound commands', that'll display the commands/bindings you want. | |
Re: All the pointers in the [icode]reg[/icode] array end up pointing to the one and only buffer [icode]line[/icode] that you have. So, every time fgets() grabs new data, any pre-set pointers in the array automatically point to the newly fetched data - the previous data is simply overwritten. | |
Re: >> Does anyone know the event that causes the carriage return animation to play? I believe you've coined a new term for a thing which is more commonly known as a [I]caret[/I]. Perhaps read up about [URL="http://msdn.microsoft.com/en-us/library/ms646968%28v=VS.85%29.aspx"]Carets[/URL] and see if it's possible to achieve what you want. | |
Re: The errors boil down to the RationalInfo() function, even though you are not calling it from anywhere, the compiler wants it to be OK, so fix it first or remove it if don't need it [CODE] int RationalInfo (int initialArray[][B][MAX][/B]) { [B]// You still need to declare the variables a … | |
Re: Since you are using the same [icode]ifstream[/icode] object throughout the do/while -loop, you need to call [icode]tempsynth.clear()[/icode] whenever .open() fails. Otherwise the object remains in fail state and makes no attempt to open any further files. By the way, are you initializing the random number generator (i.e. calling [icode]srand()[/icode])?. | |
Re: >> I could say i find the limit of microsoft's product in engineering computing. Perhaps see [URL="http://msdn.microsoft.com/en-us/library/aa366778%28v=VS.85%29.aspx"]Memory Limits for Windows Releases[/URL]. | |
Re: [QUOTE=bobbuilder67;1119087]So does anyone know of how I should edit stdafx.h to get his program to work?[/QUOTE] Unfortunately editing stdafx.h will do no good. It is a MFC program you have there, and the VC Express won't be able to compile it like jonsca ^said^. If you know someone, who's familiar … | |
Re: Line #75, connects the last node to the one specified (i.e. temp2) - why? Probably not what you want. | |
Re: >> I gave up and used a bash call .. Maybe give it another try .. adding a [icode]curl_easy_perform(curl)[/icode] call there might work wonders ;) | |
Re: >> 'book_list' : undeclared identifier In Main.cpp line #26, the missing variable has been commented out, so you need to remove the comments to have the [icode]book_list[/icode] declared. [code] ... // Declare the book list and an STL linked list variable list <BookRecord> book_list; ... [/code] On a side note, … | |
Re: >> Here is the same code similar to the C code in C++ to save you the bother. >> Thread Solved. Sorry, but I think you should [URL="http://www.daniweb.com/forums/thread78060.html"]Read This Before Posting[/URL] .. scroll down to the "Don't give away code!" section. | |
Re: To me it's unclear what the program actually is about precisely, but would [URL="http://msdn.microsoft.com/en-us/library/ms648383%28v=VS.85%29.aspx"]ClipCursor()[/URL] be accepted? | |
Re: [QUOTE=pigg;805622] Yes, as your advice, i add the output of "n", the result is "1026".(it should be 0x402) By the MSDN: 0x402 An unknown error occurred. This is typically due to an invalid path in the source or destination. This error does not occur on Windows Vista and later. So … | |
Re: Would it be possible to provide a compilable example program only including the few (?) necessary classes? Have you tried this code with other compilers? | |
Re: >> i was able to fix more errors! Nice. >> there is only one left! Even better, I think the error comes from the line #19. Since [icode]Aux[/icode] and [icode]Actual[/icode] both are of type [icode]CNoFila *[/icode], I'm [I]guessing[/I] that your intention was to write .. [code] // Set Aux to … | |
Re: See [URL="http://www.parashift.com/c++-faq-lite/templates.html#faq-35.16"][35.16] Why do I get linker errors when I use template friends?[/URL] | |
Re: >> I have got core dump by [I]running this code[/I] I'm echoing what griswolf said .. post [I]the actual code[/I] that gave/gives you the core dump. The code you've posted should not compile with any compiler - because of the missing ')' (line #8). Anyhow, assuming that your crashing program … | |
Re: >> Error 1 - error C2011: 'Controller' : 'class' type redefinition 9 An unfortunate space character has slipped in, preventing the definition of the intended [icode]CONTROLLER_H[/icode] macro .. Controller.h [code] #ifndef CONTROLLER_H // #define CONTROLLER _H // <--- wrong #define CONTROLLER_H // <--- right #include "LevelFolders.h" ... [/code] | |
Re: If your compiler supports [icode]long long[/icode], you may [LIST] [*] get lucky with [icode]std::stringstream[/icode] [*] have [icode]strtoll()[/icode] at your disposal [/LIST] Though, as Banfa noted, your code will not be standard C++. | |
Re: >> I am getting a really weird unhandled exception What is the exact error message? (there are many exceptions) Are you using Visual Studio? | |
Re: >> [I]test.cpp:3:18: error: stream:[/I] There isn't a header file named <stream> in standard C++. Looks like you'd rather want to; #include <string> | |
Re: It should be [icode]__declspec[/icode], so .. [code] #define PLUGIN_EXPORTABLE __declspec(dllexport) [/code] >> Also I don't understand what the warning below means >> warning: no newline at end of file You need to add a new-line character at the end of the file. If you don't, your C++ program has undefined … | |
Re: At least the [icode]stats[/icode] constructor needs some attention, see the comments below. [code] <snip> while(i<(d_data->nCols*d_data->nRows)){ d_data->data[i]=datap->data[i]; // 'i' gets incremented too early here i++; // Upon last iteration; i == d_data->nCols*d_data->nRows, which is wrong uchar n = datap->data[i]; // .. then, the damage is done here ... d_data->data[i]=n; uchar m … | |
Re: WinBGI [I]might[/I] do the job. See vegaseat's code snippet; [URL="http://www.daniweb.com/code/snippet216433.html"]Add WinBGI Graphics to your Console[/URL]. There's a link to a site from where you can get what's needed -- note that you also need to get a new compiler. | |
Re: Also note that HP-UX's malloc() may fail if you e.g. have previously tampered with the allocated memory. See [URL="http://docs.hp.com/en/B2355-60105/malloc.3C.html"]http://docs.hp.com/en/B2355-60105/malloc.3C.html[/URL] - scroll down to DIAGNOSTICS. | |
Re: Looks like nbaztec and jonsca sorted your problems out. However, I'd like to point out a basic thing that you've been doing wrong, namely "number_of_users = ++number_of_users". Do not write code like that, see [URL="http://c-faq.com/expr/ieqiplusplus.html"]comp.lang.c FAQ list · Question 3.3 [/URL] | |
Re: I'm guessing that [ICODE]initgraph()[/ICODE] fails there and the program just silently exits (i.e. calls exit(1)). [EDIT] After looking up [URL="http://www.cs.colorado.edu/~main/bgi/doc/initgraph.html"]initgraph()[/URL] it's clear that the teacher gave you a bad example (perhaps intentionally?). Anyway, you have to change the call to [ICODE]initgraph()[/ICODE] so that it matches the function's signature. | |
Re: Just a suggestion in case this ICODE button re-appears. Would it be possible to display it as e.g. "INLINE", instead of the previous "ICODE"? I think that would cut down the number of posts with code snippets encased in ICODE tags (there are lots of those). | |
![]() | Re: [QUOTE=iamthwee] I trying to get the [I]LAST modified[/I] [/QUOTE] Then you want to use [icode]ftLastWriteTime[/icode]. [QUOTE] to decide which text file is the most recent[/QUOTE] You can directly compare the FILETIMEs using [URL="http://msdn.microsoft.com/en-us/library/ms724214%28v=VS.85%29.aspx"]CompareFileTime()[/URL] |
Re: [QUOTE=rootchord] In function ‘bool operator<(const Student&, const Student&)’: ../src/Student.cpp:25: error: passing ‘const Student’ as ‘this’ argument of ‘int Student::getscore()’ discards qualifiers [/QUOTE] Your compiler is trying to tell you that you want to declare the getscore() and getname() methods as [ICODE]const[/ICODE]. So, instead of stripping away constness, you might rather … |
The End.