1,296 Posted Topics
Re: Look at an interesting discussion about C++ file extensions: [url]http://stackoverflow.com/questions/152555/h-or-hpp-for-your-class-definitions[/url] There are others C++ header file extensions in use: .hh, .hxx et al | |
Re: Some notes about isdigit and non-ascii characters: The isdigit is a C library function (the C library is a part of C++ library) so let's open the C language standard: [quote]The header <ctype.h> declares several functions useful for classifying and mapping characters. In all cases the argument is an int, … | |
Re: Think a little: 1. Look at the partition returned type: must be const Type& or int ??? [code=cplusplus] template< typename Type > const Type &partition( Type* array, int low, int high ) { int left, right; ... return right; // integer value returned, not const Type& !!! } [/code] Look … | |
Re: Alas, probably not only division is not working for ALL numbers in this code... Can you explain what are you doing? | |
Re: Well, but WHAT are your problems? | |
Re: A rather strange loop, see what happens: [code=cplusplus] while (cardsRemoved<participants) { int r = 0; // r created on every loop, initialized 0 kanban[r][c]=kanban[r][c]-1; // always [0][c] = [0][c] r++; // incremented, but r shall die soon cardsRemoved++; // automatic r ended } [/code] Probably you forgot that the loop … | |
Re: [quote]...unsigned short integer is ALWAYS 1 char long[/quote] That's wrong statement. The "length" of unsigned short value is [icode]sizeof(unsigned short)[/icode]. The length of char value is ALWAYS 1 by the language definition. Now try to print [icode]sizeof(unsigned char)[/icode] and see what happens. 1. What's array called number type? Show me … | |
Re: Fortunately you CAN'T invent a "class of no designated size" in C++. For every class its objects have fixed and defined size (remember operator sizeof). If you mean a class with dynamically allocated members then it's a problem of this class constructor, not a vector container. That's why class constructors … | |
Re: Don't use Dev-C++: the project is frozen 1. VC++ 2008 Express: ~400 Mb (with MSDN Express) + >100Mb Windows SDK: [url]http://www.microsoft.com/express/download/#webInstall[/url] 2. Code::Blocks IDE with MingGW compiler (G++ from gcc family Windows port) -~20 Mb: [url]http://www.codeblocks.org/downloads/binaries[/url] Both compiler implement (almost) C++ Standard (if you don't use MS .NET VC++ "extensions"). … | |
Re: There are interesting sentences about main in the C++ and C standards. C++: [quote]An implementation shall not predefine the main function. This function shall not be overloaded. It shall have a return type of type int, but otherwise its type is implementation-defined. All implementations shall allow both of the following … | |
Re: What happens - see my post in the recent thread [url]http://www.daniweb.com/forums/thread156711.html[/url]. You can't modify string literal via pointers, on modern platforms you catch memory access exception. So in your 2nd snippet str2 points to the same C-string literal address - that's all. If you modify str1 value (for example, [icode]str1 … | |
Re: Fortunately, it's so simple: [code=cplusplus] std::string s; s = "Base "; s += "next item. "; s += "The end."; [/code] | |
Re: 1. We suggest a topic. 2. You create some problems. 3. We cope with your problems. 4. You have working Turbo C++ project. Right? ;) Free enterprise pattern w/o feed-back circuit... Human civilization was started from division of labor... | |
Re: Insufficient info. As usually, no function definitions in the header. Where are these functions bodies? The linker can't obtain them. Check out all sources, libraries and the project settings. | |
Re: [QUOTE=k59smooth;738215]where can i get good a C++ compliler[/QUOTE] [url]http://www.codeblocks.org/[/url] [url]http://www.microsoft.com/express/download/#webInstall[/url] | |
Re: [QUOTE=clutchkiller;738203]My dev-c++ compiler is telling me that ios::noreplace is not a valid member of std::ios. Why?[/QUOTE] Because no ios::noreplace in C++ at all (10 years or more): [url]http://www.devx.com/tips/Tip/14544[/url] | |
Re: A reference in C++ is another name of an object. The fun() function returns a reference to the local int variable called a. After [icode]int& r = fun();[/icode] r is another name of INEXISTENT object: local (automatic) variable a (int object in automatic atorage - usually stack) of fun does … | |
Re: Alas, modern computers are very fast beastes but not so fast as you wish... Think: you define 600851475143 loops (~10^12 times). I'm too lazy to profile your code but I'm sure that your (and mine) computer is not capable to perform more than 10^8 (or near) this loop bodies per … | |
Re: [code=c] while((ch==getche()) != 'd') [/code] I see you like C operator ==, but it's equal test operator, not assignment (operator=). You are trying to COMPARE ch with getche() returned value. But you never assign the value to ch. | |
Re: Regrettably, all <ctime/time.h> stuff does not bear a relation to the computer Real Time Clock device. Moreover, you can't directly access RTC in standard Windows user mode. | |
Re: Better read the excellent tutorial "All about pointers": [url]http://eternallyconfuzzled.com/tuts/languages/jsw_tut_pointers.aspx[/url] | |
Re: Of course, it's my opinion only: 1. ? Ask AV soft implementors ;) 2. Yes, of course. Look at the VC++ Project Types pane. If you wish VC++ generates code which does not depend on .NET framework. Of course, you can't use any .NET stuff in the code. 3. Yes … | |
Re: Of course you have "memory leak" because you never deallocate pointers to dynamically allocated country names placed in dynamically allocated countryList array of pointers. You deallocate the array of pointers only. | |
Re: In actual fact it does not matter in C and C++ where a function prototype was placed if it stands before function using. What a (bad) compiler are you using? Apropos, why you compute simplest x*x as pow(x,2.0)? You don't test input results. Try to enter (misprint) not-a-number... Avoid using … | |
Re: Why devious ways to go? [code=c] char* reverse_case(char* str) { if (str) { char* p; int c; for (p = str; (c=*p) != 0); ++p) if (isalpha(c)) *p = (islower(c)?toupper(c):tolower(c)); } return str; } [/code] | |
Re: Don't pursue mirages. Floating point arithmetics is binary, not decimal. Strictly speaking, no such double values as 0.45 or 0.1. Both real numbers are periodical binary fractions but it's impossible to represent infinite series of 0/1 exactly in 64-bit words (more precisely in 53 bits, see [url]http://en.wikipedia.org/wiki/IEEE_754#Basic_formats[/url]). All double values … | |
Re: May be it helps: [url]http://support.microsoft.com/kb/90530[/url] I don't test it because I never used global variables (it's true ;) ). | |
Re: The [icode]assign(const char*)[/icode] wants C-string terminated by zero byte. You forget to assign [icode]buffer[lsize] = '\0';[/icode] after fread. It's enough to raise erratical memory access error in assign. Another notes: 1. No need to rewind pFile, use fseek again. 2. Think about exit() in C++ programs. Automatic objects destructors are … | |
Re: There are (at least) two defects in this short solution: 1. Try to type "HowManyPhantomZeroesPushed:1-2-3-4-5..."... 2. Strictly speaking, the last char of std::string value[i] is not equal to 0. Index value must be less that value.length(). Declare a const char pointer initialized by value.c_str(). | |
Re: [QUOTE=love_dude1984;736520]hi everyone.. i just want to know which of following operator can't be overloaded. a)== b)++ c)?! d)<= hoping for a Answer ASAP with explanation.. thanks..[/QUOTE] At first find an error in your question ;) | |
Re: No need in two loops. Search this forum for Fibonacci series (there are lots of recent threads on this topic). | |
Re: Well, it's so simple (in C++ ;) ): [code=cplusplus] struct Record { char q[100]; char a1[100]; ... Record() { memset(q,0,sizeof q); memset(a1,0,sizeof a1); ... } void read() { ... }; .... Record YourRecord; ... [/code] | |
Re: Regrettably, this very strange operator+= overloading is legal in C++. Present the code fragment where these errors were detected. I'm sure it's wrong code fragment incorrectly used the 1st overloaded operator. | |
Re: What's a problem? Do not declare this static member array as const - that's all. At first YOU say to compiler that "it's a constant array, don't allow ME to change it" - then cry ;)... | |
Re: Probably, semicolon or closed brace (or both) missed just before line 872 or near (may be in header file). Check syntax carefully. Look at the title of your post. Are you sure that it's an error in the C++ language or compiler? ;) | |
Re: Is it a joke? end == end is always true (if you don't overload operator ==, of course). What's a sense of humor ;)... | |
Re: The yearofstart member of struct customer variable does not bear a relation to struct yearofstart variable. You don't initialize this last (of struct date type) member of customer. It's a global variable so all its members initialized with 0. | |
Re: YOU show us some code. Consider a proper using of floor() library function. | |
Re: You must delete array pointer by [icode]delete [] pointer[/icode] operator. In other words a pointer obtained from [icode]new[][/icode] must be deleted by [icode]delete [][/icode]. Learn C++ more carefully ;) ... | |
Re: Some notes about previous post. 1. The fgets function was supposed but an example used another function fgetc. It defines while loop incorrectly because s variable is uninitialized at the start loop moment. This loop icorrectly prints possible on eof returned value (see #2). 2. EOF is not "a special … | |
Re: Too many errors... That's your homework, not mine, so I can't write the right code for you. Some (free ;) ) advices: 1. Next time use code tag with language specifier: [noparse][code=c] ... sources ... [/code][/noparse] 2. Reread Runge-Kutta RK4 method description, for example: [url]http://en.wikipedia.org/wiki/Runge-Kutta[/url] 3. Declare all variables as … | |
Re: Obviously it's not C++ issue. It's your DBMS issue. Use the DBMS transactions. | |
Re: Can you explain what do you want to do really? All presented code looks like an absolutely senseless coding exercise... | |
Re: Have you ever search INET for arithmetic expressions parsing&evaluation? Try that, there are lots of info and codes on this old good topic... | |
Re: Use more compact, fast and robust stream control in the last function: [code=cplusplus] void somefunction(istream& bs) { string x; while (getline(bs,x,',')) cout << x <<'\n'; cout.flush(); } [/code] | |
Re: It's a UNICODE string. Use WideCharToMiultiByte to convert share name to ordinar string. May be better try NetShareGetInfo? Apropos, "No special group membership is required for level 0 or level 1 calls" only... | |
Re: No need to pass references to arrays. In actual fact a pointer to a 1st element of an array passed. Array contents never copied when passed as argument. What for all these ordinar functions are collected in a class? | |
Re: Keep it simpler, it's C++, not Pascal ;) : [code=cplusplus] //checks for leap year bool checkLeapYr(int year) { return year%4 == 0 && (year %100 != 0 || year%400 == 0); }//end function check leap year//checks for leap year [/code] | |
Re: [quote]it doesnt really explain whats going on under the hood[/quote] Ok, it's a simple but not a strong validation. For example, in most of C implementations scanf can't detect integer overflow (it's possible to type a huge number and to get some wrong number with scanf(...) == 1). More strong … | |
Re: A string literal is a constant value in modern C and C++, so the pointer to it has [icode]const char*[/icode] type (not [icode]char*[/icode]). The Melarki constructor wants char* argument. Why? It's a very dangerous class. For example, your program is evidently wrong: Melarki destructor called for wholeMelarki will try to … |
The End.