1,296 Posted Topics
Re: 1. It DOES NOT work because you forgot to double backslashes in the file name string literal (see point #3 example in your snippet). 2. ? No platform-independent solution. 3. ShellExecute is a direct way to do the same job... | |
Re: You are trying to print an uninitialized and unexistent abc[3] element of abc array of pointers to int... It's the hexadecimal representation of this value... | |
Re: [code=c++] #include <iostream> using namespace std; struct deneme { int a; void (* myFunction)(int a); void look4adventures() { myFunction(a); } }; void function1(int a) { cout << a << endl; } void function2(int a) { cout << a + a << endl; } int main() { deneme myDeneme[] = {{1,function1},{2,function2}}; … | |
Re: [QUOTE=number87;793850]Hi guys I just wanna ask what is the difference between the mode_t and st_mode when using sys/stat.h and sys/types.h libraries. I looked them up google and find most people use st_mode but never mode_t.[/QUOTE] The [b]mode_t[/b] is a type alias. The [i]st_mode[/i] is a name of the struct stat … | |
Re: As far as I know COSMIC compilers automatically generate assembler output in modulename.s files ( ? )... | |
Re: Honestly speaking, I can't understand your true problem. It seems no need in function pointers in your code at all. For example, xSquared member function does not bear a relation to the class Int, it does not use any class members. Evidently, it's an ordinar function: [icode]double sqr(double x) { … | |
Re: To change file name extension try this code: [code=c] /** Find dot extension pos in the file path. * Returns dot pos or end of name if no dot * or 0 if it's not a file name */ const char* getFileNameDotPos(const char* fname) { int i, ilast, slen; char … | |
Re: The order of evaluation of operands of the operator << is unspecified by the C++ Standard. Therefore both cases in the original snippet are ill-formed. It's another case of the famous bad code example [icode]a[i] = ++i;[/icode] ;) The order of operands evaluation (from left to right) is defined for … | |
Re: [code=c] void Pyr(int N) { if (N >= 0 && N < 26) { const char* z2a = "ZYXWVUTSRQPONMLKJIHGFEDCBA" + (26 - N); int i, j, d, dist, mid = N+N - 2, n = 4*N - 1; for (i = 0; i < N; ++i) { dist = i … | |
Re: 1. What's a strange source file format: MS Word doc?! Have you ever heard about cpp/h or even txt files? 2. Where is the data file and its format description? 3. What's your program environment (OS & compiler)? 4. [b]What's your problem?[/b] | |
Re: The true funny thing is that it's a VERY simple "algorithm": make a loop from 0 to 2^n-1 and print the binary representation of the loop counter (a very simple thing too). Don't worry about n > 32: you can't print (or store) more than all 4 billion combinations for … | |
Re: As usually, a container iterator is not typedef only, it's a class. It seems your solution have at least two defects (apart from incorrect syntax): 1. Your list container users want LIST abstraction, not LIST NODE one. 2. It's a class declares some classes or ordinar functions as friends, a … | |
Re: 1. Use code tags for snippets: [noparse][code=c++] sources [/code][/noparse] 2. As usually user defined class name are capitalized. 3. The class1 [b]destructor[/b] (not [i]deconstructor[/i] ;)) must delete an array of pointers to class2. Formally no need in class2 destructor when you delete an array of pointers to class2, an operator … | |
Re: Google search: md5 c source sha1 c source Tons of links right now ;)... | |
Re: [QUOTE=cppnewb;773261]Is it free? Microsoft Visual C++ express edition?[/QUOTE] Yes, VC++ 2008 EE is free. You must download ~400 Mb (VC++, MSDN EE and, probably, Windows SDK). It's the best C++ IDE for Windows but see the distribution size... Another good choice - Code::Blocks IDE with MinGW C++ compiler ~20 Mb. | |
Re: [QUOTE=Bladtman242;771861]What do you suggest I do about the gotos? I knew you would't like it,but why?[/QUOTE] Look at [url]http://david.tribble.com/text/goto.html[/url] (not from a mobile device ;) ) | |
Re: It's possible to convert a pointer to derived class to a pointer to a base class, but this rule does not bear a relation to Derived** => Base** conversion. Compare: [code] Derived* => Base* // derived-to-base pointers conversion, OK Derived** == (Derived*)* => (Base*)* == Base** // Type1* to Type2*, … | |
Re: Obviously you can't get access violation at this statement. Possible cause: stack corruption (for example, overwriting of return address) or bad (uninitialized) pointer in your code (outside of GetCellX function call). Try to go through step by step with debugger. | |
Re: Look at [url]http://richardbowles.tripod.com/cpp/linklist/linklist.htm[/url] or/and [url]http://www.inversereality.org/tutorials/c++/linkedlists.html[/url] Now you can't declare linked list node correctly. Start from the beginning in 2009 ;)... | |
Re: Some remark (to the original post). The [icode]Point newPos = myPos + yourPos;[/icode] construct is not an assignment (that's why you compile w/o errors). It's default copy constructor [icode]Point(const Point&)[/icode] makes an initialization. Free advice: if you overload an assignment operator then (as usually) you are supposed to define a … | |
Re: [b]String s = "anything"[/b] is not an assignment, it's [b]initialization[/b]! So you must define a proper [b]constructor[/b]: [code=c++] class String { public: String(const char*); ... }; String s = "This constructor called!"; String t("The same constructor called!"); [/code] | |
Re: 1. Wrong main prototype. Must be: [code=c] int main(int argc, char*argv[]) [/code] 2. fgetc returns int, declare c as int. 3. No need in rewind(fp1). Test fp1 == 0 befory any ops with opened file. 4. Test argc == 3 (argv[0] - program name, argv[1] and argv[2] - file names). … | |
Re: [QUOTE=Bladtman242;767984]altso i never really considered which compilers are better or worse, so does anyone know about code::blocks? im using that :)is it ok?[/QUOTE] Code::Blocks is not a compiler, it's a cross-platform Integrated Development Environment (IDE): [url]http://en.wikipedia.org/wiki/Integrated_development_environment[/url] See also [url]http://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#C.2FC.2B.2B[/url] The Code::Blocks IDE supports lots of C++ compilers on Windows, Linux … | |
Re: [QUOTE=Comatose;770962]Missing ; after } for class prototype: [code]class circuit { public: int append_and_file(stack<int> &); /* Some other variables defined */ };[/code][/QUOTE] Remark: this constuct called [b]class definition[/b] in C++. | |
Re: For example, download free [b]Matrix TCL Lite 1.13[/b] by Techsoft: [url]http://www.techsoftpl.com/matrix/download.htm[/url] (it's not a recommendation, I never use this library but it's compact and simple;) ). Comment 5 lines of abs definitions in downloaded matrix.h: [code=c++] /* Do that, you can't compile it with VC++ when <complex> included #if ( … | |
Re: s10(2^1000) == 1366 2^1000 == 1071508607186267320948425049060001810561404811705533607443750388370351 05112493612249319837881569585812759467291755314682518714528569231404359845775746 98574803934567774824230985421074605062371141877954182153046474983581941267398767 559165543946077062914571196477686542167660429831652624386837205668069376 ;) | |
Re: [QUOTE=amerninja2;768247]<Snipped URL> = [url]http://www.programming-wizard.synthasite.com[/url][/QUOTE] Hmm... Ajax and HTML are not programming languages. Ajax is a technology, HTML is a markup language... ;) | |
Re: Did you want an array of atoms? Possible answers: 1. I don't understand you. 2. You don't know any arrays of... ? | |
Re: it's not STL, it's libstdc++, list.cc module: [url]http://www.cs.brown.edu/~jwicks/libstdc++/html_user/list_8cc-source.html[/url] [code] 00123 void 00124 _List_node_base::hook(_List_node_base* const __position) 00125 { 00126 this->_M_next = __position; 00127 this->_M_prev = __position->_M_prev; 00128 __position->_M_prev->_M_next = this; 00129 __position->_M_prev = this; 00130 } [/code] ;) | |
Re: It seems you like adventures: [code=c++] struct Int { Int(int n = 0):value(n){} operator int&() { return value; } operator const int&() const { return value; } Int& operator=(const char* p) { value = (p?atoi(p):0); return *this; } Int& operator=(const std::string& s) { *this = s.c_str(); return *this; } int … | |
Re: [code=c++] inline time_t addDays(int days) { return time(0)+86400*days; } time_t printNewDate(int days) { time_t newtime = addDays(days); std::cout << asctime(localtime(&newtime)); return newtime; } [/code] The time() function declared in <ctime> header returns current time in seconds. Seconds per day: 24*60*60 == 86400. Need more? ;) | |
Re: 1. It's absolutely clear and ordinar member function call via a pointer to the object (with single argument). 2. Again it's not a syntax related question, syntactically it's a very simple construct. There are two standard macros in C and C++: __FILE__ - expands to the current source module name … | |
Re: [QUOTE=death_oclock;768425]Just put all the function definitions in one header file and have all the other headers include it. That way every function knows about every other function.[/QUOTE] That's the worst solution. Now you have a huge scrap heap of all possible interfaces. It's hard to maintain such a heap, you … | |
Re: After that think again. It seems you have wrote absolutely senseless code with this awkward jumble of std::string and C-string oriented snprintf ;)... | |
Re: [QUOTE=cam875;768859]how do i make it so that functions and procedures that are located in other files in the include statement have access to the global variables within main.cpp, thanks in advance.[/QUOTE] As usually: main.cpp: [code=c++] ... bool troublesWanted = true; bool IlikeBadDesign = true; ... int main() { ... } … | |
Re: [QUOTE=firstPerson;768843]how would I check how long a program takes for it to be completed. (i.e the time it takes for the program to be finished doing its calculation)) Thanks[/QUOTE] Make 10% of calculations then multiply elapsed time to 9 ;)... | |
Re: Look at [url]http://www.audiomulch.com/~rossb/code/lockfree/ATOMIC.H[/url] | |
Re: Alas, my conclusion is: [b]too many defects[/b]. 1. I have never seen float type version number. It's cool! 2. I don't understand why nobody can declare arrays of NameValuePair (default constructor is private). Everybody can assign arbitrary values to both pair members via setters but it's impossible to define default … | |
Re: ASCII-EBCDIC Chart: [url]http://www.natural-innovations.com/computing/asciiebcdic.html[/url] | |
Re: Better look at another page of this tutorial (you may change MFC to Forms etc): [url]http://www.winprog.org/tutorial/apivsmfc.html[/url] No need to study flight dynamics to fly in business class. But if you want to join the F-35 project team... | |
Re: 1. Try to avoid exit function in C++ programs. Use [icode]return 1;[/icode] to exit from main on errors. 2. Library names are placed in namespace std. You must open these names visibility by using directive ([icode]using namespace std;[/icode]) or using declaration ([icode]using std::ifstream;[/icode]). 3. [code=c++] std::ifstream infile("input.txt"); if (! infile) … | |
Re: [QUOTE=Murtan;766376]dougy83 you could make that assignment to hold the allocation, but to me it looks like a memory leak waiting to happen and in a professional setting I would fail your code review for it. [/QUOTE] It depends on context. For example, it's all right in a proxy class implementation: … | |
Re: I think that one of the most promising C++/web technologies is FastCGI. Look at [url]http://cryp.to/publications/fastcgi/[/url] FastCGI combines the C++ power and comfort programming environment with extremely fast reactiveness and scalability... | |
Re: [QUOTE=somnathsarode;766256]hi , everybody can any one write a "c" programme without main() function "please don't tell me this is not possible " If u know please tell me[/QUOTE] Of course, it's possible in freestanding environments, see the C Std: [quote]Two execution environments are defined: freestanding and hosted. In both cases, … | |
Re: Some remarks about exit() in C: The exit call considered harmful in C++ but not in C where "a return from the initial call to the main function is equivalent to calling the exit function with the value returned by the main function as its argument" (C Std, 5.1.2.2.3 Program … | |
Re: No need in extern keyword for external function declarations. Use function prototypes to declare function interface: [code=c++] int some(); // No function body: it's a function declaration. ... // Now compiler knows that some is a function name. int some() { ... // That's a function definition. } [/code] You … | |
Re: [code=c] char onetwo[3]; /* for one, two, zero chars */ char one, two; one = getche(); two = getche(); onetwo[0] = one; /* array indicies started from 0 */ onetwo[1] = two; onetwo[2] = '\0'; /* c-string terminated zero byte */ /* Now you have well-formed c-string */ printf("echo: %s\n",onetwo); … | |
Re: Well if you have VS 2008 Pro then you have a very complete MSDN help installed ;)... Continue?... | |
Re: For VC++ 9 (2008): Create/open the project then menu: [b]Project|Properties[/b] then select [b]Configuration Properties|General[/b] and set [b]Character Set[/b] to [b]Not Set[/b]. I don't know how to do that in VC++ 8 (2005) but I suspect the same procedure... | |
Re: Quick pointer answer: you DON'T DEFINE ptr pointer variable but use it. [code=c++] int *ptr; // Now ptr has a garbage value (points to nowhere) int var; ptr = &var; // Now ptr points to var. *ptr = 5; // Now var has value 5. [/code] |
The End.