6,741 Posted Topics

Member Avatar for vegaseat

main returns int, and you should validate the input somewhere or all hell could break loose. Good idea though, and a nice start.

Member Avatar for jnawrocki
3
1K
Member Avatar for tformed

>is there any way one could do a square root program without sqrt or pwr functions? No, those functions are magic. There's no way you can simulate their behavior in C++ without pixie dust or phoenix feathers. One might assume that if you know how the mathematics work, you could …

Member Avatar for vmanes
0
3K
Member Avatar for bob89

[URL="http://www.eternallyconfuzzled.com/libs/jsw_avltree.zip"]This library[/URL] is written in C, but it allows duplicates. The duplicate check is actually an [I]extra[/I] step for insertion because proper duplicate handling falls out of the usual binary search tree insertion logic. Keep in mind that the above library treats duplicates as a stack. When searching and deleting, …

Member Avatar for paladin.lone
0
338
Member Avatar for dalaharp

>I don't know what language your are using so I'm being vague. You could assume either C or C++ and probably hit the mark. :rolleyes: >is there any function available to enable it?? Poor man's profiler: [code] #include <stdio.h> #include <time.h> clock_t start = clock(); /* Code you want timed …

Member Avatar for rustysynate
0
3K
Member Avatar for derbende

>Can robot be coded in C++ Of course it can. >I thought AI languages like Lisp ,etc are more suitable for that? Suitable and capable aren't synonyms.

Member Avatar for stephendstump
0
1K
Member Avatar for onlyremedy
Member Avatar for c-work

Look through the recent threads. Not only have I explained a simple way of writing an archiver several times in the last two weeks, I've also posted sample code.

Member Avatar for krsna90
0
150
Member Avatar for serkan sendur

I'm assuming you mean a buffer in the context of a stream. A stream is a sequential list of items where (in the simplest sense), the source places a single item at a time onto the stream and the destination extracts a single item in the order of insertion. In …

Member Avatar for stavrianosy
0
1K
Member Avatar for Chandrakumar

That's Visual Basic, not C or C++. Please direct your question to a more appropriate forum.

Member Avatar for rajeev_cv_2012
0
298
Member Avatar for BevoX

You're using integer arithmetic, any precision will be lost before the result is assigned to your float variable. Convert one of the operands to a floating-point type and it should work: [iCODE]((float)end - start) / CLOCKS_PER_SEC[/iCODE].

Member Avatar for Microno
1
678
Member Avatar for Asif_NSU

>What should i do? Post a reply to the thread that this question is concerning rather than starting a new one so that we have a clue what you're talking about. ;)

Member Avatar for Musa_Jutt
0
3K
Member Avatar for kakilang

This is an implementation-dependent operation. Without knowing your platform and compiler, we can't help you at all.

Member Avatar for ganeshchhetri
0
1K
Member Avatar for starletcharmed

Most of your problems can be fixed by using a stack of characters instead of strings: [code=cplusplus] #include <iostream> #include <stack> using namespace std; int main() { stack<char> s; char a; cout << "Enter: " << endl; while ( cin.get ( a ) && a != '\n' ) s.push(a); while …

Member Avatar for d_a_y_o
2
4K
Member Avatar for Hojjat.Mojallal

One big decision you need to make in merging is whether it's destructive or not. Are you going to remove nodes from each list and add them to the result, or copy the data into new nodes? Either way the merge works as a traversal. Select between the two lists …

Member Avatar for mandeepsukhwinderparmar
0
4K
Member Avatar for djbsabkcb

>however when I use a large number such as 100 or more it takes forever It will also probably produce incorrect results. Fibonacci numbers grow at such a large amount that unless N is small, you'll overflow a long. Even using unsigned long to protect against undefined behavior and extend …

Member Avatar for josh2k12
0
2K
Member Avatar for bemo55

>gets(char[i]); FYI, booze in fact does [b]not[/b] improve your ability to write code. You'd have to be quite confused to write char[i] when you meant firstname[i], and any experienced C programmer would have to be drunk to use gets.

Member Avatar for jcmoney1010
0
9K
Member Avatar for Redhaze46

[B]>is it possible to create my own simple programming language in c++?[/B] Of course it's possible. But it's harder than you probably think.

Member Avatar for mrnutty
1
230
Member Avatar for idRATHERgoHUNT

I don't know of any, but keep in mind that the game you're looking for will either be gimped due to lack of funding or overloaded with ads and other ways of generating revenue beyond a subscription. p.s. WoW sucks, Everquest 2 is where the cool people play. ;)

Member Avatar for remixedcat
-2
2K
Member Avatar for JuliaCplus

>i can sort 2 strings but can't sort 3 strings. If you can sort two strings, you know how to sort three. This is especially easy because there's a smallest, a largest, and only one inbetween. So all you need to do is find the smallest and largest before you …

Member Avatar for NathanOliver
0
923
Member Avatar for brahle

>Always use scanf() and printf(). Dangerous overgeneralization. >They are much, much faster than cin and cout. Uninformed generalization. >Also use stl algorithms, like sort, reverse and find, especialy >if they are member functions of a container class you use. This is actually good advice, though I would have worded it …

Member Avatar for neithan
0
2K
Member Avatar for suhrud.l
Member Avatar for Slate2006

If it's actually an array, there are two common ways to find the size. The first is a template that converts an array of type T to an array of type char, which can then be used as the operand to sizeof to get the number of elements: [code=cplusplus] #include …

Member Avatar for Sebelius
0
1K
Member Avatar for addicted

>system("cls"); Brilliant. So what happens if I replace the Windows cls with my own malicious cls? You've just given me control, thanks! This is what's called a back door, and you left it wide open by using an insecure technique.

Member Avatar for Bob
0
2K
Member Avatar for lovetwins01

Post your code using code tags. You can find out how in the FAQ or just about any of the stickies. If you still can't figure it out, post your code anyway and a moderator will tag it for you (just this once though).

Member Avatar for krissybhabhie
0
2K
Member Avatar for donial

How about a phonebook? Or an inventory system? Something that uses a simple database will be more than sufficient for a "data structure" project because you're forced to use or design a suitable data structure.

Member Avatar for rubberman
0
227
Member Avatar for michelle1

[B]>If you expect your IDE to come fully featured then it won't be lightweight....[/B] The very definition of IDE implies a text editor, a compiler, a debugger, and build tools. vim is a text editor, not an IDE. That's why developers work with several individual tools such as vim, gdb, …

Member Avatar for Abdelghafour
0
716
Member Avatar for narendharg

A static function is a function with the static qualifier applied: [code] static void foo ( void ) { /* Blah blah */ } [/code] What it does is restrict visibility of the function to the translation unit in which it's declared. Functions are implicitly declared as extern by default, …

Member Avatar for nitin1
0
638
Member Avatar for cortiknee

>Though remember sprintf() does not calculate for buffer overflow. Neither does itoa. ;) >A safer version of sprintf() is snprintf() which unfortunately isn't very standard yet. It is standard, but the standard just isn't widely implemented yet. As it is, C89 is the dominant C standard, and snprintf is nothing …

Member Avatar for dverex
2
15K
Member Avatar for BradenMurphy

>can anyone tell me how to make it so the PC doesn't use 100% cpu? It uses 100% CPU because you're using a busy loop to pause. A true fix for the problem is "don't do that". Use some form of pause that puts the thread to sleep without affecting …

Member Avatar for Ancient Dragon
0
205
Member Avatar for Azurea

[ICODE]system("pause")[/ICODE] represents an unsafe programming practice. Not only is the argument to the system function non-portable (your code would work on Windows but not Linux, for example), someone could replace the "pause" program on the machine with a malicious program and use it to cause trouble. Spoofing a legitimate program …

Member Avatar for WaltP
0
617
Member Avatar for aasi007onfire

>what does the assignment statement (*s++=*t++) return each time it gets executed It doesn't return anything. An assignment expression evaluates to the new value of the left-most operand.

Member Avatar for Ancient Dragon
0
193
Member Avatar for ND2

We can't tell you what's wrong with your logic if you don't post the pseudocode you have. Don't expect us to give you the solution.

Member Avatar for stuart.mwalo
0
184
Member Avatar for n3red

It makes more sense to work from the least significant bit (assuming your string isn't reversed), in my opinion: [code] #include <string.h> int to_int(const char *bin, int *result) { size_t len = strlen(bin); int bit_value = 1; int temp = 0; if (len > 32) return 0; while (--len < …

Member Avatar for Rajkumarautit
0
333
Member Avatar for bohm13rit

>This is how I would do it You would use a recursive function for a problem clearly unsuited to a recursive solution? That's a shame.

Member Avatar for teachMyself
0
957
Member Avatar for jepapel

This is a somewhat slow solution because you end up with an expensive search, but it does what you want. The alphabet string holds all of your valid characters and the values array has the corresponding value at each index. Once you have the index for alphabet, you can get …

Member Avatar for slumburock
0
4K
Member Avatar for daviddoria

>Is there a reason that I shouldn't just do this in the first place? It depends on your debugging needs. If the assertion is absolutely critical for the application to continue, [i]and[/i] the information from a failed assert is sufficient, by all means use assert. On the other hand, if …

Member Avatar for vibhor48
0
294
Member Avatar for Aghtar

Two biggest problems: [list=1] [*][ICODE]count[/ICODE] and [ICODE]counts[/ICODE] are never initialized. You should initialize them both to 0. [*]In your averaging loop, you always use [ICODE]lows[MAX][/ICODE]. It should be [ICODE]lows[i][/ICODE]. [ICODE]lows[MAX][/ICODE] doesn't exist. [/list]

Member Avatar for NathanOliver
0
134
Member Avatar for aasi007onfire
Member Avatar for deceptikon
0
278
Member Avatar for lulug76

[url=http://www.nist.gov/dads/HTML/bucketsort.html]Clickie[/url]. Bucket sort isn't as common of a term as you might think. It's actually more common to hear about variants such as radix sort.

Member Avatar for deceptikon
0
195
Member Avatar for lostinthespiral

>The following link may be helpful I doubt it, unless the OP is still having trouble with this assignment three years later. :icon_rolleyes:

Member Avatar for deceptikon
0
833
Member Avatar for mainak001

You appear to have two Perl related questions, so I'm moving this thread to the Perl forum.

Member Avatar for neha1811
0
1K
Member Avatar for NetJunkie

[QUOTE]When did you start programming and what language did you start in?[/QUOTE] I started in 1996 with C. Technically my first language was COBOL, but it was too brief of a time to be meaningful. ;)

Member Avatar for Reverend Jim
0
967
Member Avatar for Human01

>if you think this guy knows what he's talking about I'm sure you're simply trying to be witty, but speaking of yourself[1] in the third person is generally viewed as highly pompous. A smiley would go a long way toward helping us understand that you aren't [i]really[/i] that arrogant. >has …

Member Avatar for Keath Moore
1
439
Member Avatar for kutuup

An unresolved external error is typically telling you that you've declared but not defined a function. In this case, the constructor for your Tree class. I notice that your destructor isn't implemented either, unless you're defining them in a separate file.

Member Avatar for pubudu1199
0
150
Member Avatar for blez

[QUOTE=khotraj;1627662]Dear morons. 400mb ram and 20 gigabytes was unimaginable when C++ was made. At that time 1mb Hdd was too much and ram was less that 256Kb. check this thread out mate, and if u can modd ur phone, you can probably run Windows 95 on it as well. check …

Member Avatar for vijay.kanta
0
1K
Member Avatar for kephieubat
Member Avatar for GuruGhulab

>i don't know if that's the rite procedure. The string class is designed to act like a first class type, so the operations you use on numbers should work for string objects as well. There are a few problems with your code though. >int nTemp; nTemp is the temporary storage …

Member Avatar for sameershah21
0
3K
Member Avatar for CertifiedMan

[QUOTE]Oracle Certified Java Programmer? Useless.[/QUOTE] Indeed. For that certification all I got was a silly lapel pin. Nobody asks if I'm certified and takes it on faith that I know what the hell I'm doing from previous successful projects.

Member Avatar for jbennet
0
191
Member Avatar for Mongooseman
Member Avatar for jnmisa

[QUOTE]Which way is the best to learn, Either to use Microsoft Visual C# or Notepad?[/QUOTE] It's beneficial to learn how to invoke your tools manually rather than rely on an IDE like Visual Studio, but not required immediately. I'd suggest starting out with an IDE for ease of use, then …

Member Avatar for jussij
0
157

The End.