- Strength to Increase Rep
- +16
- Strength to Decrease Rep
- -4
- Upvotes Received
- 174
- Posts with Upvotes
- 160
- Upvoting Members
- 69
- Downvotes Received
- 5
- Posts with Downvotes
- 5
- Downvoting Members
- 5
Re: If you include <cmath> sqrt function lives in std namespace. So declare [icode]using namespace std;[/icode] or (better) use std::sqrt(...) or declare [icode]using std::sqrt;[/icode]. Probably, that's all your troubles now... | |
Re: The Language Primary Source: [quote]simple-escape-sequence: one of ' \" \? \\ \a \b \f \n \r \t \v ... Alphabetic escape sequences representing nongraphic characters in the execution character set are intended to produce actions on display devices as follows: \a (alert) Produces an audible or visible alert without changing … | |
Re: From [url]http://homepages.cwi.nl/~dik/english/mathematics/armstrong.html:[/url] [quote]An Armstrong number is an n-digit base b number such that the sum of its (base b) digits raised to the power n is the number itself.[/quote] a = a^1 { 1, 2, 3, 4, 5, 6, 7, 8, 9 } ab = a^2 + b^1 {} abc … | |
Re: Well, start from this forum announcement: [url]http://www.daniweb.com/forums/announcement8-2.html[/url] | |
Re: The VC++ now defines CLOCKS_PER_SEC (old CLK_TCK) macros as 1000, so there are no bad scaling in that case. However a real measured interval (i.e. VC++ RTL clock() precision) is about 15 milliseconds, so it's impossible to measure short intervals (iterative variant with clock() ticks <2 MICROseconds!). For example, look … | |
Re: Generally speaking, it's an absolutely senseless operation to compile header file with a single class definition. No correspondend code (object module) generated. May be the compiler go off its head while performing such an action ;),,, | |
Re: Probably, all beginners write verbose and heavy-to-read codes. Don't complicate your as it is not so easy life with monstrous switches. Use this common approach: [code=cplusplus] const char* numeral[] = { "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve" }; ... cout << numeral[num] << … | |
Re: A user-defined main() is not the first (and the only) function in the executable module. Have you ever heard about sturtup code? A console mode program has opened i/o streams - it's a job for startup code. It has a properly initialized memory heap - it's a job for startup … | |
Re: Sorry, but it's impossible to read your snippet. Please, use code tag properly: [noparse][code=c++] sources (with line breaks) [/code][/noparse] | |
Re: Of course, you can do that. It's called recursion. The only problem is to break recursive call chain in the proper moment. In other words you must prevent f() call which calling f() which calling f() again and so on... | |
Re: Use double (not float) type for math calculations! [code=c] double x, y, z, sum, pi; ... sum = 1.0; for (i = 0, y = 3.0; i < n; ++i, y += 2.0) { z = 1.0 / y; if ((i & 1) == 0) sum -= z; else sum … | |
Re: Look at [url]http://dbkgroup.org/handl/ants/[/url] | |
Re: Apropos, I far as I know, [icode]rand() % N[/icode] (where rand() is a pseudo-random numbers generator) is NOT uniformely distributed in 0..N-1 range... Right (but cumbersom) construct is (alas): [code=cpp] (int)(N*(rand()/(double)MAX_RAND)) [/code] | |
Re: 1. If you are using stdafx.h (in MS VC++), place all system includes in stdafx.h, not in your source modules. 2. Why [icode]#include "stdio.h"[/icode]? Must be [icode]#include <stdio.h>[/icode] directive in stdafx.h. | |
Re: You have a class Tools with these (and others) member functions. Remember a syntax of member function call: [code=cplusplus] object.member_function_name(parameters) // or pointer_to_object -> member_function_name(parameters) [/code] So, for your test (member!) function call you must write, for example: [code=cplusplus] #include "Tools.h" ... int main() { Tools tools; ... tools.test(); ... … | |
Re: Never use old Borland C++ compilers (except for dog fights with deviations of C++ standard). The [b]best[/b] free C++ compiler + IDE now is VC++ 2008 Express edition, of course. Regrettably, its distribution size is ~200 Mb + ~200 Mb for MSDN Expess (if you want more than rudimentary help) … | |
Re: I think, it's an absolutely aimless article (and discussion too), because of VTBL is not a part of C++ language. If you want to know how virtual functions calls were implemented in the specific C++ implementation. search Google (or what else;)), for example: [url]http://forums.msdn.microsoft.com/ru-RU/vclanguage/thread/0e2d1b36-1805-46de-afe8-ce7b6348fe28[/url] [url]http://bytes.com/forum/thread535605.html[/url] I have no time to … | |
Re: Also pay attention: getchar(), getc(), fgetc() functions return int (not char) values. In essence, char type in C (but not in C++) is a very short int, that's all. | |
Re: 1. Hamming distance for binaries: [url]http://en.wikipedia.org/wiki/Hamming_distance[/url] 2. Use CODE tag for snippets: [noparse] [code=c] your sources [/code][/noparse] | |
Re: Some remarks. Regrettably, niek_e's solution is a solution of another problem. It can replace one word only, not an arbitrary substring. Ancient Dragon's solution uses RTL library (not in spirit of original post, see length() function instead of strlen). [code=c] /// For this example only: inline int length(const char* s) … | |
Re: I think we have an impressive example of a false problem. If you want to clear console window in portable manner, use portable direct console i/o library (pdcurses, for example, or others). That's the only right answer. May be a suitable ersatz of such libraries is <conio.h> stuff implemented with … | |
Re: I think it's an example of incorrect help request. I'm sure that you can't implement ZigBee protocol stack in C from the scratch. Look at TI Z-Stack free product (ZigBee compliant protocol stack): [url]http://focus.ti.com/docs/toolsw/folders/print/z-stack.html[/url] - download ~13 Mb zip. So it's not a problem - it's impossible for lonely heroes … | |
Re: [code=cplusplus] bool cvtLPW2stdstring(std::string& s, const LPWSTR pw, UINT codepage = CP_ACP) { bool res = false; char* p = 0; int bsz; bsz = WideCharToMultiByte(codepage, 0, pw,-1, 0,0, 0,0); if (bsz > 0) { p = new char[bsz]; int rc = WideCharToMultiByte(codepage, 0, pw,-1, p,bsz, 0,0); if (rc != 0) … | |
Re: See also http://michael.dipperstein.com/sqrt/index.html | |
Re: Try this simplest program, look at these codes on your screen: [code] #include <stdio.h" #include <conio.h> /* Press Esc to quit */ #define ESC 27 int main() { int ch; while ((ch=getch()) != ESC) { printf("%d",ch); while (kbhit()) { printf(" %d",getch()); } printf("\n"); } printf("ESC %d\n",ch); return 0; } [/code] … | |
Re: I don't understand why this ancient thread is vivified. It's impossible to get an array size by array parameter only. For slow-witted reanimators: it's impossible in C and C++ to get a size of array argument by this array parameter only. You all reanimators forget that: 1. An array parameter … | |
Re: 1. Start from [url]http://en.wikipedia.org/wiki/Regular_expression[/url] 2. Select, download and install one of C regex libraries. 3. Get the library manual, read it carefully and see examples in the distributive... | |
Re: Face value definition: [url]http://stats.oecd.org/glossary/detail.asp?ID=5945[/url] [url]http://www.sutton.com/dictionary/face+value+of+a+loan[/url] | |
Re: Some notes to OP code: Next time (rather always) try to separate interface and calculation (processing) modules (functions). For example, it's a very useful function: [icode]long getJulianDay(int y,int m, int d)[/icode]. You (and others) can use it in console or GUI programs. You can use it in the displayjulianDates function … | |
Re: It seems this zombi thread was started by incorrect and unclear question then proceeded with answers to another hypothetical questions and now start the next bla bla bla loop... ;) That's my deposit in the discussion of char to int promotion... |