1,296 Posted Topics

Member Avatar for marcosjp

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...

Member Avatar for marcosjp
0
165
Member Avatar for serkan sendur

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...

Member Avatar for BevoX
0
72
Member Avatar for serkan sendur

[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}}; …

Member Avatar for serkan sendur
0
104
Member Avatar for number87

[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 …

Member Avatar for number87
0
99
Member Avatar for sarawilliam

As far as I know COSMIC compilers automatically generate assembler output in modulename.s files ( ? )...

Member Avatar for ArkM
0
98
Member Avatar for ozan

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) { …

Member Avatar for ozan
0
132
Member Avatar for Lolly2009

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 …

Member Avatar for ArkM
0
221
Member Avatar for WaelTheNoble

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 …

Member Avatar for WaelTheNoble
0
140
Member Avatar for asharrajpoot

[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 …

Member Avatar for me_ansh
0
188
Member Avatar for nimalka

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]

Member Avatar for Salem
0
91
Member Avatar for dparas

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 …

Member Avatar for ArkM
0
1K
Member Avatar for c++noobie

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 …

Member Avatar for c++noobie
0
354
Member Avatar for mini programmer

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 …

Member Avatar for mini programmer
0
195
Member Avatar for massivefermion

Google search: md5 c source sha1 c source Tons of links right now ;)...

Member Avatar for skatamatic
0
78
Member Avatar for cppnewb

[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.

Member Avatar for John A
0
137
Member Avatar for Bladtman242

[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 ;) )

Member Avatar for Bladtman242
0
116
Member Avatar for mini programmer

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*, …

Member Avatar for mini programmer
0
130
Member Avatar for heimdhal

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.

Member Avatar for ArkM
0
159
Member Avatar for Olsi009

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 ;)...

Member Avatar for kbshibukumar
0
117
Member Avatar for nitrooreo

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 …

Member Avatar for nitrooreo
0
309
Member Avatar for u8sand

[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]

Member Avatar for u8sand
0
99
Member Avatar for nitu_thakkar

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). …

Member Avatar for Ancient Dragon
-1
136
Member Avatar for Bladtman242

[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 …

Member Avatar for Bladtman242
0
164
Member Avatar for guest7

[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++.

Member Avatar for Comatose
0
142
Member Avatar for 35nando

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 ( …

Member Avatar for 35nando
0
2K
Member Avatar for mrnutty

s10(2^1000) == 1366 2^1000 == 1071508607186267320948425049060001810561404811705533607443750388370351 05112493612249319837881569585812759467291755314682518714528569231404359845775746 98574803934567774824230985421074605062371141877954182153046474983581941267398767 559165543946077062914571196477686542167660429831652624386837205668069376 ;)

Member Avatar for Rashakil Fol
0
141
Member Avatar for amerninja2

[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... ;)

Member Avatar for amerninja2
0
146
Member Avatar for cam875

Did you want an array of atoms? Possible answers: 1. I don't understand you. 2. You don't know any arrays of... ?

Member Avatar for cam875
0
118
Member Avatar for dwhite409

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] ;)

Member Avatar for dwhite409
0
163
Member Avatar for Clockowl

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 …

Member Avatar for Clockowl
0
112
Member Avatar for cppnewb

[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? ;)

Member Avatar for cppnewb
0
9K
Member Avatar for Richy321

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 …

Member Avatar for Salem
0
126
Member Avatar for death_oclock

[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 …

Member Avatar for death_oclock
0
156
Member Avatar for tom_jerry042

After that think again. It seems you have wrote absolutely senseless code with this awkward jumble of std::string and C-string oriented snprintf ;)...

Member Avatar for iDeveloper
0
157
Member Avatar for cam875

[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() { ... } …

Member Avatar for ArkM
0
247
Member Avatar for mrnutty

[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 ;)...

Member Avatar for stonerain
0
111
Member Avatar for amt_muk
Member Avatar for cikara21
0
99
Member Avatar for tymk

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 …

Member Avatar for tymk
0
132
Member Avatar for smnadig

ASCII-EBCDIC Chart: [url]http://www.natural-innovations.com/computing/asciiebcdic.html[/url]

Member Avatar for ArkM
0
1K
Member Avatar for Manutebecker

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...

Member Avatar for Manutebecker
0
91
Member Avatar for agentkirb

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) …

Member Avatar for agentkirb
0
128
Member Avatar for fireballnelson

[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: …

Member Avatar for ArkM
0
169
Member Avatar for Alex Edwards

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...

Member Avatar for iluxa
0
334
Member Avatar for somnathsarode

[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, …

Member Avatar for ArkM
0
153
Member Avatar for Relative0

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 …

Member Avatar for ArkM
0
82
Member Avatar for Ronen444

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 …

Member Avatar for Murtan
0
129
Member Avatar for kikloo

[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); …

Member Avatar for Murtan
0
268
Member Avatar for I_want_to_lean
Member Avatar for ArkM
0
105
Member Avatar for Frederick2

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...

Member Avatar for Frederick2
0
134
Member Avatar for CPPRULZ

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]

Member Avatar for JoBe
0
130

The End.