278 Posted Topics

Member Avatar for lochnessmonster

It depends on the instruction, there are shortcuts for longer commands, which in assembly are 2 or 3 'words' but in binary are just 1 opcode. As an example: xor eax,eax Is smaller than mov eax, 0 Also, take a relative jump for example - it's 5 bytes, but a …

Member Avatar for thelamb
0
193
Member Avatar for SacredFootball

[QUOTE]The result doesn´t need to be a number with a decimal.[/QUOTE] How do you know? 0_o Anyway, we need more info: How is this function called? (e.g. how are arrayStart and arrayEnd initialized). Could it be a problem of an edge case? [code=cpp] for (tempPtr = arrayStart; tempPtr != arrayEnd+1; …

Member Avatar for SacredFootball
0
157
Member Avatar for deanus

It will be a dangling pointer, so just be allocated for nothing. Because you overwrote ptr, you can't call delete[] anymore on the original ptr.

Member Avatar for ravenous
0
136
Member Avatar for Akill10

You mean what value m_item will hold? That depends on the type of DataType. It's default constructor will be called, without any parameters. If DataType is an int, it will behave just like 'int m_item;' would. Not sure if this is exactly your question though (just had an exam from …

Member Avatar for Akill10
0
153
Member Avatar for Szeth

>> is simply a function call, which can fail. So check if the cin >> userGuess succeeded or not: [code] if( ! (cin >> userGuess) ) // not an integer, do something [/code] (the () around cin >> userGuess are important.)

Member Avatar for Szeth
0
381
Member Avatar for mackemforever

Google for 'cin' and C++. Also, you're now using the C function for output (printf), in C++ we generally use 'cout'.

Member Avatar for mackemforever
0
124
Member Avatar for caut_baia

What do you want to achieve with this: [code=cpp] B () : x(y) { B <t-1> (); // What do you think happens on this line? } [/code] The design currently makes very little sense. Does the assignment specifically state 'array', if so then you probably are not allowed to …

Member Avatar for caut_baia
0
98
Member Avatar for LeMajestique

In C++ NULL is defined as 0, so it won't make a difference. (The use of NULL is even discouraged by some, including Stroustrup).

Member Avatar for thelamb
0
601
Member Avatar for johans22

Consider this: [code=cpp] HANDLE fHandle; for( int i = 0; i < 7; ++i ) { fHandle = CreateFile( ... ); } close( fHandle ); [/code] First time CreateFile is called, let's assume that fHandle will be set to 0x00000001. The next time it's set to 0x00000002, until 0x0000007. After …

Member Avatar for thelamb
0
141
Member Avatar for tehmarto

That's not an easy thing to do. Do you have any other information what this function supposedly does? Does it show a message box? Does it print something? Does it write a file? etc.

Member Avatar for thelamb
0
313
Member Avatar for airerdem

There are several ways, look at std::sort: [url]http://www.cplusplus.com/reference/algorithm/sort/[/url] By default it uses the operator<, so you can create a class that inherits from vector and overload the operator<. Or, more easily create a 'compare' function and hand it over to sort. After you've sorted the vectors, you can iterate through …

Member Avatar for Fbody
0
174
Member Avatar for AnkitPasi

You run the program, select the option that will read the file, then the program closes and you re-open. You then select the option that will print the data that was previously read? That won't work. In the first instance, the data is read into memory. All of that memory …

Member Avatar for thelamb
0
326
Member Avatar for lius84

compile with symbols, execute `ulimit -c 1024` (will create a core dump when your program segfaults), then use gdb on the core dump, and tell it where your source files are so that it can tell you where the error originates. How can you manage a 14k line program without …

Member Avatar for mike_2000_17
0
181
Member Avatar for Annettest

A templated function doesn't _need_ to be defined in the header file, however it is usually easier to do so (see [url]http://stackoverflow.com/questions/115703/storing-c-template-function-definitions-in-a-cpp-file[/url] ). Inline functions however need to be in the header file, this has to do with 'translation units'. If you have an inline declaration in 'inline.h' and it's …

Member Avatar for thelamb
0
242
Member Avatar for shawnhanna

Run your code under a debugger (You use Visual Studio after all) to get more detailed information about the crash. The pasted code is too long to read through when the range can be narrowed down very easily ;)

Member Avatar for shawnhanna
0
700
Member Avatar for MasterGberry

You're not actually modifying the inTables[q].Items in your first loop. [code=cpp] for each (AoE2Wide::DrsItem item in inTables[q].Items) { // item is a copy of what's at inTables[q].Items, modifying item will leave the item in inTables[q].Items in tact } [/code]

Member Avatar for MasterGberry
0
90
Member Avatar for rebellion346

I dont think you fully understand what templates are for, let's look at the name setter for example: [code] template <typename N> N setName(N n) { Name = n; return n; } [/code] Why do you need a template function here? Name is always a string. So this would do …

Member Avatar for mike_2000_17
0
124
Member Avatar for jusami

Do you know what a class is? Have you learned anything about object oriented programming?

Member Avatar for thelamb
0
108
Member Avatar for Mr_PoP

First post I thought I spotted an error in pQuery, since this is rather weird: [code] sprintf(buf,""); int ret = vsprintf(buf + strlen(buf) [/code] the strlen put me off. The real error is that you can't compare a char array with ==, there are functions to do this (e.g. strcmp, …

Member Avatar for Mr_PoP
0
111
Member Avatar for SpecialForce

In write_it (I guess that is where it crashes?), check what the value of 'buf' is, is it a valid pointer? I don't know how this 'curl' library works though, so just guessing here

Member Avatar for mike_2000_17
0
1K
Member Avatar for Infame

You're not receiving anything, it prints uninitialized data. You set the socket to 'nonblocking' and then continuously call recv. So even if there is no data coming from there server, recv will return. You do not check the return value of recv before printing it, the return value is probably …

Member Avatar for thelamb
0
135
Member Avatar for alonewolf23
Member Avatar for mrnutty
0
135
Member Avatar for ziggystarman

For one, MD5 shouldn't be used any more. And it's going to be fairly trivial to bypass this. A reverser can just put a breakpoint on when your program attempts to open a file.. this is going to be somewhere at the beginning of the 'check license file' function. He …

Member Avatar for ziggystarman
0
311
Member Avatar for SoftwareAbuser

[QUOTE]tei.h:56:10: warning: multi-character character constant[/QUOTE] 'T0' is not a character, it's two characters. [QUOTE]tei.h:7: error: aggregate ‘foititis p’ has incomplete type and cannot be defined[/QUOTE] Where is 'foititis' declared? Is this declaration available in tei.h ?

Member Avatar for thelamb
0
3K
Member Avatar for indr

What happens here: [code=cpp] char* a = "Hello world"; cout << a; [/code] a is a char*, so cout starts printing until it finds a null character. It prints Hello World. [code=cpp] char a = 'p'; cout << &a; [/code] a is a char, but &a is also a char* …

Member Avatar for embooglement
0
152
Member Avatar for Mr_PoP

You can't execute another query, without freeing the last result. So you need to do one query, use the results, free the results, do the next query etc.

Member Avatar for Ancient Dragon
0
210
Member Avatar for AmerJamil

There are many ways to do this.. Why do you ask if your solution is correct? You can check it for yourself by printing the first 11 values of f, to see if they match a. Your declaration of 'main' is bad.. I hope the teacher did not show you …

Member Avatar for abdelhakeem
0
155
Member Avatar for MasterGberry

[quote]Basically I want to be able to implement the C# code that occurs into C++ code instead.[/quote] Your question is a bit vague... Do you want to execute C++ code from this C# program so that you can replace it 'in small parts'? If yes... don't even try. What I …

Member Avatar for MasterGberry
0
260
Member Avatar for gpta_varun

No, notice the & sign before tc_a? This means tc_a is a reference. So tc_a will reference p, which essentially makes them one and the same object. Have you ever used references in function parameters? If not.. this is a good time to read about it ;)

Member Avatar for gpta_varun
0
134
Member Avatar for thelamb

I'm designing an exception class, but ran into a case where a copy is being made which I don't want (plus, I don't understand why). Consider the following cases: [code=cpp] // 1 Exception e; throw e; // Copy: yes //2 throw Exception(); // Copy: no //3 throw Exception() << "extra …

Member Avatar for thelamb
0
95
Member Avatar for MAbebe

Think about what you're doing. You want to start j at i + 1, is there any orther variable that you could use for this, that IS defined at for( int j=... ) ? If you declare a variable inside the for statement like this, it is ONLY visible inside …

Member Avatar for FutureWebDev
0
455
Member Avatar for Dingbats

There are several ways... Create a file on startup, and remove it again on exit. If on startup the file already exists, then refuse to start. Or.. a better way: Create a mutex in the global namespace(CreateMutex @msdn) on startup and destroy it on exit. If the creation fails with …

Member Avatar for Dingbats
0
1K
Member Avatar for cplus++

How can we help you if we don't know what your program needs the access for... And how do you know it's not working - is there are an error code like that says access is denied?

Member Avatar for cplus++
0
246
Member Avatar for jeffpro

Tell us what you need to do please, without knowing some more details it's hard to suggest something.

Member Avatar for jeffpro
0
609
Member Avatar for Taggize

You are printing everything... in the while( ! eof ) there should be an if before the cout. You have 1 'code' variable, that you both use for the input from the user (cin >> code) and when reading from the file(getline(..,code,..)). You need two variables.. one for the user …

Member Avatar for ravenous
0
179
Member Avatar for Marissak

Depends on the type you're reading.. If you store the user input as string, you can access the individual numbers(characters) just like you would with an array: [code=cpp] string test = "12345"; test[0]; // '1' test[4]; // '5' [/code]

Member Avatar for Marissak
0
236
Member Avatar for abugslife

Better show us the code.. You probably have the implementation of this class in two .cpp files

Member Avatar for abugslife
0
81
Member Avatar for cameclifton

When someone is 'tenured' it means that they can not be fired without a 'good reason'. In C++, a 'Boolean' is 'bool'. So you can just give the class a member 'bool m_tenured;'

Member Avatar for thelamb
0
149
Member Avatar for tomtetlaw

It goes wrong in free. sizeof( mem ) will be the size of a void*, not the size that was previously requested in Alloc. Also.. be careful with pointer arithmetic: [code=cpp] char* pChar = 0; pChar++; // pChar will be 1 int* pInt = 0; pInt++; // pInt will be …

Member Avatar for tomtetlaw
0
265
Member Avatar for petmol

[code=cpp] while (start == 1) cout << "\n"; [/code] Those two lines will be executed forever, you need to indicate all the code that belongs inside the while loop by putting it in { }'s

Member Avatar for petmol
0
130
Member Avatar for ScreamingPsycho

[code=cpp] if(nextLetter==phrase[i]); [/code] There is a ; after the if, so letterFound will _always_ be set to true. Edit: Also, I think it would be cleaner to use for loops instead of while... the use of while is confusing in this case, and it is very easy to forget the …

Member Avatar for ScreamingPsycho
0
155
Member Avatar for pato wlmc
Member Avatar for harryhaaren

When you add a Looper, it is 'sliced' to it's base class. What you need to do is store pointers or references to AudioTrackElement, they will 'preserve' the class hierarchy. So: [code=cpp] AudioTrackElement* pNewEl = new Looper(); pNewEl->process( ... ); // calls Looper::process delete pNewEl; Looper newLoop; AudioTrackElement newEl = …

Member Avatar for harryhaaren
0
230
Member Avatar for smrati.katiyar

sizeof is a compile-time 'function'... it cannot get the size of dynamic arrays. So, your code is very wrong... your intention is to write 3 items into a, but there is only space for 0 items.

Member Avatar for VernonDozier
0
86
Member Avatar for rena0514

You are calling a function 'isEmpty()'. That does not exist anywhere, does it? If you want to check if a stack is empty, you can call 'empty()' on the stack. So: [code=cpp] while( !myStack.empty() ) [/code]

Member Avatar for thelamb
0
253
Member Avatar for MairiRobertson

I have use Code::Blocks for a long time (code completion was close to absent in the old version, but improved greatly in the latest. If you stick to nightly builds it's even better). I still use C::B if I have to develop on Linux, but for Windows I switched to …

Member Avatar for mike_2000_17
0
163
Member Avatar for DarthMustard

Interesting... Haven't thought about this much, but I guess a relatively straight forward method is to store the sClient on the heap, hand a pointer to it over to the thread.. and then copy it to the thread's local storage, finally free the memory you allocated on the heap in …

Member Avatar for thelamb
1
753
Member Avatar for kevintse

This will work, because the hard coded strings are stored in the strings section of your executable, and s just points to that. After the function returns the string will still be there. static storage is if you declare a variable like this: [code=cpp] void myFunction() { static int myStatic …

Member Avatar for kevintse
0
129
Member Avatar for yardi

Here on Daniweb you won't get much help without showing some effort of yourself. What have you done yourself? Have you ever programmed in C++ before? If not, start doing (hands-on) tutorials.

Member Avatar for ravenous
0
125
Member Avatar for NU8

The front/rear is a little confusing. If I push two items, rear will increase by 2. front remains unchanged, but in holds() you output front. So, that explains why holds() gives the wrong size?

Member Avatar for NU8
0
122

The End.