436 Posted Topics

Member Avatar for power_computer

There are three steps to inserting in an array: [LIST=1] [*]Find the position of the item being inserted. [*]Make room for the new item by shifting all items from that position forward one spot to the right. [*]Copy the new item into the position that was vacated. [/LIST] Graphically it …

Member Avatar for Tom Gunn
0
115
Member Avatar for Ismailworking

[QUOTE]when i press Ctrl+F9 , the output screen comes and goes without stopping for a while. Please note that i have included "#include<stdio.h>" and i am using "getchar()" function do stop the screen. [/QUOTE] A previous call to scanf() of getchar() is probably leaving characters in the stream. The getchar() …

Member Avatar for ankur_
0
10K
Member Avatar for xxDivineVinny

That class has a kind of strange way of implementing a failed search. In the constructor you pass a bogus object that will act as the sentinel value, and find() returns that object if it fails. So in your case you will compare [ICODE]mytree->find(joe)[/ICODE] against [ICODE]bob[/ICODE], since you passed [ICODE]bob[/ICODE] …

Member Avatar for Tom Gunn
0
234
Member Avatar for MrNoob

Yes, null bytes with a value of 0x00 are used as padding for alignment purposes.

Member Avatar for MrNoob
0
105
Member Avatar for PDB1982

Are you doing something like the following? It works OK on my end for simple currency: [code] #include <iostream> #include <iomanip> int main() { double values[] = { 12.501, 1254.0, 124.15, 10321, 1.1256 }; const int sz = sizeof values / sizeof *values; std::cout.imbue(std::locale("")); for (int x = 0; x …

Member Avatar for restrictment
0
112
Member Avatar for NinjaLink

I get all stacks being equal because you call printStack() on both operands and printStack() pops the contents away. Both stacks are always empty. When doing these tests, make sure that you are clearing out the stack at the right time.

Member Avatar for Tom Gunn
0
1K
Member Avatar for SerenaG

The getline() method works with char pointers, and the non-method getline() works with string objects.

Member Avatar for Tom Gunn
0
54
Member Avatar for number87

It works OK for me. Maybe the problem is how you are printing the double that atof() returns. What does the following program print when you run it? [code] #include <iostream> #include <iomanip> #include <string> #include <cstdlib> int main() { std::string s("500.00"); std::cout << std::fixed << std::setprecision(2) << std::atof(s.c_str()) << …

Member Avatar for mrnutty
0
177
Member Avatar for brijendra_kumar

[QUOTE]how we can check a linkedlist of char have a palindrom or not [/QUOTE] The same way you do it with an array. Walk two iterators from each end toward the middle until they meet. If the iterators match the whole way, the sequence is a palindrome. Of course, if …

Member Avatar for Tom Gunn
0
95
Member Avatar for aalice

[QUOTE]hw can i make x and y give me the lowest form of the rational numbers [/QUOTE] Do you mean you want to [URL="http://cboard.cprogramming.com/c-programming/24494-reducing-fractions-entering-fraction-form.html"]reduce a fraction[/URL]? [QUOTE][CODE] HERE: scanf("%d", &v); if(v==0) { printf("Don't use 0 \n"); goto HERE; } [/CODE][/QUOTE] [ICODe]HERE[/ICODE] is a terrible name for a goto label. But …

Member Avatar for Tom Gunn
0
160
Member Avatar for seo2005

[QUOTE]1. Whether I can use ASCII code for to print special symbols, like I have done above in 3 cases.[/QUOTE] What are special characters? Are they the glyph characters that are neither digits nor latin alphabet characters? Are they control characters? What about extended characters? All of the above? You …

Member Avatar for Tom Gunn
0
291
Member Avatar for khitab12

[QUOTE]so no one has solved it still............[/QUOTE] If anyone has bothered, they will not post the code. It is counterproductive and against Daniweb's rules to help people cheat on their homework.

Member Avatar for Phil++
-2
108
Member Avatar for desimator55

[QUOTE]Are you using the <string> header?[/QUOTE] [icode]System::String[/icode] is not the same as [icode]std::string[/icode]. The former is the .NET framework's string class that is used in C++/CLI code. [QUOTE]I have trolled the interwebz looking for an answer and can't find anything helpful.[/QUOTE] Your question is a Microsoft [URL="http://support.microsoft.com/kb/311259"]knowledge base article[/URL]. It …

Member Avatar for Ancient Dragon
0
273
Member Avatar for necrolin

What do you mean by "it's not working"? Are you getting a compile time error? A run time error? "It's not working" is not a helpful description of the problem.

Member Avatar for necrolin
0
203
Member Avatar for nehemiascr

[QUOTE]Can anyone help me with the algorithm for the height of a n-ary tree, I have been looking and could only found for a binary tree[/QUOTE] The basic algorithm is the same. The only difference is that instead of just following the left and right links, you follow n links. …

Member Avatar for Unix*
0
648
Member Avatar for tiara

[QUOTE]const just says the function will not change anything [/QUOTE] Kind of. const can only be applied to methods, and it means two things: [LIST=1] [*]The immutable state of the object will not be changed within a const method. [*]The const method can be called by objects that are declared …

Member Avatar for Ancient Dragon
0
112
Member Avatar for maey_kich

Traditionally it is done with a header file and an implementation file: [code] // myarray.h #if !defined(MYARRAY_H) #define MYARRAY_H #define MYARRAY_SZ 100 extern int myarray[]; #endif [/code] [code] // myarray.cpp #include "myarray.h" int myarray[MYARRAY_SZ]; [/code] [code] // main.c #include <iostream> #include "myarray.h" int main() { for (int x = 0; …

Member Avatar for Tom Gunn
0
95
Member Avatar for 17ashis

Both and neither. Your question is much too vague to answer. Any objective comparison needs to be very specific about what is being tested and using equivalent code.

Member Avatar for necrolin
0
112
Member Avatar for abhipro

Usually libraries will come with a .lib or .dll file that you can link with, and headers for compiling. But if you have all of the source, you might be able to build it all fresh too.

Member Avatar for Tom Gunn
0
145
Member Avatar for monita

Look up the next_permutation() and prev_permutation() functions in the <algorithm> header. Literally, by the way. They are template functions, so you can open that header as a text document and read the implementation to figure out how it is done. :)

Member Avatar for Tom Gunn
-5
68
Member Avatar for Tom Gunn

Is it possible to add the last post part from the forum list to the favorites list? And maybe also a link to mark all favorite forums as read? :)

Member Avatar for Tom Gunn
0
106
Member Avatar for Gaiety

[QUOTE]confused here on how the mapping is done between read ,write and scanf ,printf. because read/write takes file descriptors, buffers and size of data where as printf and scanf takes the variable lenght args: format strings and arguments[/QUOTE] It is not a direct mapping. printf() for example does a lot …

Member Avatar for Ancient Dragon
0
198
Member Avatar for TechComm

The easiest way to do this is to open the .cpp file and display it using cout. As a hint for a program displaying its own code, there is a preprocessor macro called __FILE__ that evaluates to a string with the name of the current file. This is the simplest …

Member Avatar for TechComm
0
492
Member Avatar for iris88

[QUOTE]i am very poor in programming coding ... [/QUOTE] The only way to fix that is by writing code. It is best to start small and build on your achievements than to start with something too complex for your skills.

Member Avatar for Tom Gunn
0
122
Member Avatar for eliza2044

Close, but a temporary copy of the object is still an independent copy. C++ does not make reference copies of objects like Java or C#. To replace the object the iterator refers to, you need to assign to the dereferenced iterator. This will overwrite the object that it refers to: …

Member Avatar for eliza2044
0
6K
Member Avatar for Qmage

When the value of a variable changes without any kind of modifying statement on it, you should look for memory corruption like buffer overflows and bogus pointers. I can help you look for it if you can pare your code down to a small but complete program that still has …

Member Avatar for Qmage
0
402
Member Avatar for fivec

[QUOTE]is sizeof an opearator(i actually studied it as a operator but then not so serious about the things)[/QUOTE] Yes, it is an operator just like [ICODE]return[/ICODE], or [ICODE]=[/ICODE], or [ICODE]<<[/ICODE]. Sometimes it looks like a function because of parentheses around the operand, but that is just an appearance thing. Any …

Member Avatar for Tom Gunn
3
158
Member Avatar for NICEGUY123

A red black tree is more than just a binary search tree with nodes marked red and black. The structure also has to be balanced according to the red black rules. Why not do a red black insert in the first place instead of trying to convert between a simple …

Member Avatar for Tom Gunn
0
97
Member Avatar for merse

Pointers to functions and pointers to methods are not the same thing. A pointer to a method is really an offset into the class, not a real pointer with an address value. You need to make two overloads of the Integral() function. One that takes a function pointer and one …

Member Avatar for Tom Gunn
0
151
Member Avatar for Towely

To position the triangle is as easy as printing out as many spaces as the position for each line: [code] for (int x = 0; x < position; ++x) cout.put(' '); [/code] Clipping the triangle is only a bit harder. Calculate the current position and if it exceeds the width, …

Member Avatar for Towely
0
247
Member Avatar for killerqb

SAX was designed for hashing strings and is supposed to be really good for it: [code] unsigned hash(string const& key, unsigned tableSize) { unsigned hashVal = 0; for (int x = 0; x < key.length(); ++x) { hashVal ^= (hashVal << 5) + (hashVal >> 2) + key[x]; } return …

Member Avatar for Rashakil Fol
0
5K
Member Avatar for Your_mum

[QUOTE]1) Can't: #include "stdafx.h" - fatal error:file or directory not found.[/QUOTE] I would recommend that you forget stdafx.h exists. It is easier in my opinion to start with an empty project and use the standard headers than to work with VC++'s precompiled headers. The other project types all start out …

Member Avatar for Your_mum
0
184
Member Avatar for th3learner

[code] lookin dat dar string izzit dat vowuel? yup, stop lookin' nope, keepa goin' didja find it? yup, hola! nope, hola louda! [/code]

Member Avatar for mrnutty
0
118
Member Avatar for dumbncool

[QUOTE]Numbers which start with a 0.[/QUOTE] You should ask whether leading 0's should be taken into account, because if you write code that does so and it is not part of the problem, you will not get the question right. Leading 0's are usually only used as padding for display …

Member Avatar for dumbncool
0
647
Member Avatar for th3learner

[QUOTE][CODE]d=strupr(s1);[/CODE][/QUOTE] d is an array, but strupr() returns a pointer to char. That is a type mismatch on the one hand, and on the other you cannot assign to an array.

Member Avatar for mrnutty
0
94
Member Avatar for dophine

Any shared resources should be protected somehow. If the singleton is a singleton across threads and not a singleton per thread then you do need to think about concurrency errors.

Member Avatar for Tom Gunn
0
41
Member Avatar for GadiK

[QUOTE]Is there any way to make VS2005 use the Aztec C compiler commands (from Aztec BIN folder)?[/QUOTE] No, but if the code does not rely on extensions to the language/library by Aztec C, you can probably port the code to VS2005 without much trouble. I am not sure if the …

Member Avatar for Tom Gunn
0
195
Member Avatar for agr.pallav

[QUOTE]i would like to know the way we can make user enter a number in a menu reply perhaps so that he doesnt have to press the enter key[/QUOTE] For this question we need to know what compiler and OS you use because there are no portable answers that will …

Member Avatar for Tom Gunn
0
163
Member Avatar for needhelpe
Member Avatar for Dave Sinkula
-1
197
Member Avatar for edwar

Functions cannot be nested in C++. They have to be at global, namespace, or class scope. You should be able to fix the error by moving the definition of CreateAllNodes() so that it comes before the definition of main().

Member Avatar for Ancient Dragon
0
93
Member Avatar for riahc3

[QUOTE]I cant use Visual Studio 2008 (which Id like to) as it uses it own compiler.[/QUOTE] Most IDEs, including Visual Studio, can be configured to use a different compiler. I am wondering why you think gcc is the best C compiler. It is certainly good, but not really much better …

Member Avatar for jeeter19
0
395
Member Avatar for CppBuilder2006

[QUOTE]If you compile with -Wall you should've seen the warning warning C4700: uninitialized local variable 'a' used and that's because class A doesn't have a constructor.[/QUOTE] -Wall is not a switch in VC++, but that warning is thrown on the default warning level, and the "internal exception" I get when …

Member Avatar for Nick Evan
0
122
Member Avatar for Aakriti

[QUOTE]How to pass array of pointers to structures using functions in C?[/QUOTE] Pointers are very regular. Once you know the basics, you can apply those basics to any level of indirection and everything will work the same way. Start with the two basic rules: [LIST=1] [*]A pointer variable is declared …

Member Avatar for Tom Gunn
0
255
Member Avatar for seo2005

[QUOTE]Is it true that some compilers require void before main ?[/QUOTE] No. Any compiler that claims to compile C is required to allow a return value of int from main(). A return of void from main() is an extension that only some compilers allow. These two definitions of main(), and …

Member Avatar for tux4life
-1
183
Member Avatar for mauryoung

[QUOTE]maybe its a compiler issue.[/QUOTE] It is a normal result of stream I/O in C. The problem is that there is still a character left in the stream after calling scanf(), and getchar() eats it without blocking. The IDE you are using probably closes the window after main() returns, so …

Member Avatar for mythilisrini
0
190
Member Avatar for MrNoob

One thing that causes thrashing is when physical memory is filled up and spills over into virtual memory. Virtual memory is disk based instead of RAM based, so it is much slower to access data stored in virtual memory. Anything that uses RAM can potentially cause that form of thrashing. …

Member Avatar for MrNoob
0
158
Member Avatar for largedimples

[QUOTE]I also need help with push. I couldn't figure out how to complete the definition or routine for it.[/QUOTE] It looks like you are using a two way linked list for the implementation. If that is the case, push is no harder than the other operations. Push() is the inverse …

Member Avatar for Tom Gunn
0
784
Member Avatar for StaticX

Strings in C are terminated by a '\0' character, but there is no magic that stops loops on it. Nothing stops you from walking past that character if the loop does not account for it. Change your loop to something like this and it will stop in the right place: …

Member Avatar for StaticX
0
113
Member Avatar for neithan

[QUOTE]how hard is the step from making console application to real world apps?[/QUOTE] Many real world apps are also console apps, so the only real difference is that those GUI apps use a GUI library to make a pretty looking interface on top of the same kind of stuff that …

Member Avatar for neithan
0
202
Member Avatar for chescarleta18

[QUOTE][CODE]main()[/CODE][/QUOTE] If you do not specify a return type for main(), it does not mean you are exempt from returning a value. This feature is called implicit int. It means that if a data type is expected but not provided, int is assumed. So these two definitions of main() are …

Member Avatar for chescarleta18
0
189

The End.