436 Posted Topics

Member Avatar for klackey19

[ICODE]char[/ICODE] and [ICODE]char*[/ICODE] are two different types. You should audit your code looking for mistakes with pointers, because I see more than just that mismatch in terms of pointer problems.

Member Avatar for klackey19
0
891
Member Avatar for vandna
Member Avatar for The Mad Hatter

[QUOTE]Well, real geeks don't run Windows. Real geeks don't run any Microsoft products, because we understand enough about operating systems and application programs, to know that Microsoft products are total, absolute, pieces of garbage.[/QUOTE] I guess you can tweak your definition of 'geek' to mean what you want, but in …

Member Avatar for Evenbit
-5
2K
Member Avatar for Web_Sailor

[QUOTE]There is nothing C++ in this code apart from "using namespace std","cout","bool".[/QUOTE] You have a strange idea of what is and is not C++. The headers are all messed up, but if those are fixed to match what is actually used, it is all C++. Here are the right headers: …

Member Avatar for Web_Sailor
0
238
Member Avatar for Ponomous

If the problem is that [ICODE]answer[/ICODE] is 0, it is likely that you are dividing everything away. Because int does not have a precision, anything past the radix will be truncated. 1/2 is 0.5 as double, but 0 as int because the .5 is cut off.

Member Avatar for Ponomous
0
145
Member Avatar for StaticX

[QUOTE]So to conclude: in standard C there's no straightforward way to find out how many subscripts you assigned a value to.[/QUOTE] A second variable with the number of used items is straightforward. This approach is no different from a vector in C++, except for a little extra work in maintaining …

Member Avatar for Tom Gunn
0
149
Member Avatar for seraph_harim

An example might help: [code] #include <iostream> #include <cstdlib> int main() { std::size_t sz; std::cout << "Enter a size: "; if (std::cin >> sz) { int* p = new int[sz]; for (int x = 0; x < sz; ++x) p[x] = rand(); for (int x = 0; x < sz; …

Member Avatar for Campbel
1
192
Member Avatar for wanted08

[QUOTE]i tried to solve it but i couldnt get the same input ..[/QUOTE] Post your try and we can help you make it better.

Member Avatar for Tom Gunn
1
504
Member Avatar for fearthisguy
Member Avatar for Tom Gunn
0
97
Member Avatar for Gaiety

A struct with no members is not legal C. Your compiler should not allow it. C++ allows empty struct definitions, but all objects must have a size, so it will always be at least 1.

Member Avatar for Tom Gunn
0
203
Member Avatar for siggivara

Linux uses '\n' for line breaks but Windows uses "\r\n". That should not matter because the compiler should recognize and convert to and from system specific representations. It can make a difference if you open the file as binary because binary mode will disable the text conversions. I have not …

Member Avatar for Tom Gunn
0
667
Member Avatar for Janiceps

[QUOTE]please help.[/QUOTE] What do you want us to do? The only legal course of action is talking to the moderators of that forum on your behalf and convincing them to unban you. But we are random geeks, not mediators, so I cannot imagine why you are appealing to us instead …

Member Avatar for happygeek
-3
437
Member Avatar for pspwxp fan

[QUOTE]I get fed up of VC++ because i don't like the errors it throws[/QUOTE] Why do you not like the errors it throws? If it is because the errors are always confusing and do not help you fix the problem, that is a legitimate reason to look for a different …

Member Avatar for pspwxp fan
0
231
Member Avatar for lancevo3

It looks OK, but that is with a few assumptions. Can you post a complete example that fails when it should not?

Member Avatar for JasonHippy
0
100
Member Avatar for DeadJustice

You differentiate between logical and actual links. Logical links are part of an n-ary node, but represented with actual binary links. If you can do that, you will be able to figure out how to move when doing any traversal. Red black trees do this well, if you need a …

Member Avatar for DeadJustice
0
183
Member Avatar for VernonDozier

[QUOTE]Is that simply what I must do or is there a way to make it so the two functions have the same name?[/QUOTE] There is a way, but it means writing a dispatch function or macro and all of the complexity involved. It is pretty simple if you are working …

Member Avatar for VernonDozier
0
111
Member Avatar for gmauger

[ICODE]int array[4] = {1,2,3,4};[/ICODE] will work, but putting objects in headers is generally a bad idea because it is easy to accidentally define the object multiple times just by including the header more than once. Inclusion guards are only a partial fix for that problem. Can you be specific about …

Member Avatar for gmauger
0
14K
Member Avatar for lipun4u

[ICODE]string[/ICODE] is not a good name because that name is already used for the std::string class. At the very least you should put your class in a namespace. I do not have Dev-C++, so I cannot reproduce your error, but I would guess that is the cause of the error. …

Member Avatar for lipun4u
0
97
Member Avatar for Phil++

I want to say yes, but just to be sure, can you give an example of what you mean by each of those?

Member Avatar for Phil++
0
72
Member Avatar for ashok.g15

If the array is the last one in the struct, you are probably seeing the struct hack. Prior to C99 it is an unportable trick for allocating arrays in a struct: [code] #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { char s[1]; } String; int main() { /* allocate …

Member Avatar for Tom Gunn
1
951
Member Avatar for NervousWreck

The memory is on the heap, but the pointer you use to get to the memory is not. It follows the same rules as any other variable from the same scope. You can save the pointer by returning it from the function: [code] string* trArr(int transactions) { return new string[transactions]; …

Member Avatar for Nick Evan
0
94
Member Avatar for atch

There are different iterator categories. The iterators for a vector are the most flexible and they are called [URL="http://www.sgi.com/tech/stl/RandomAccessIterator.html"]random access[/URL] iterators. Lists use [URL="http://www.sgi.com/tech/stl/BidirectionalIterator.html"]bidirectional[/URL] iterators, and those do not support comparing with less.

Member Avatar for atch
0
114
Member Avatar for hket89

In general, passing by value means that a copy of variable is made with the same value and passing by reference means the variable object itself is passed. You can change the value all you want with pass by value, but the original object is not changed. With pass by …

Member Avatar for BestJewSinceJC
0
176
Member Avatar for Phil++

[QUOTE]What are instance variables please?[/QUOTE] [code] class Example { static int x; // static variable int y; // instance variable }; [/code] Instance variables are data members of a class where each object has a separate copy. They are distinct from static variables where every object of a class shares …

Member Avatar for Tom Gunn
0
105
Member Avatar for makymakaru

[QUOTE]Is pass by value and call by reference the same?[/QUOTE] No. Pass/Call by value makes an independent copy of the value for use in a function, but pass/call by reference uses the same object that was passed as an argument. Everyone likes to keep saying it, but C does not …

Member Avatar for Tom Gunn
0
103
Member Avatar for Ineedhelpplz

[QUOTE]However, my integer to hex function gets stuck in an infinite loop and I have no clue why.[/QUOTE] You never change the value of number inside the loop. The algorithm should be dividing it by 16 and storing the result, right? Also, 0 and '0' are two completely different values. …

Member Avatar for Ineedhelpplz
1
384
Member Avatar for Dlearner

Here is a simple example of one way to implement vtables in C: [code] #include <stdio.h> /* class definitions */ typedef struct Base { void (**vtable)(); int _x; } Base; typedef struct Child { void (**vtable)(); /* begin base class slice */ int _x; /* end base class slice */ …

Member Avatar for Dlearner
0
5K
Member Avatar for ross42111

I think a bigger problem is that the recursive and iterative functions do not do anything remotely similar. If this program is supposed to be comparing two equivalent algorithms that solve the same problem, it is way off target. ;) What are these functions supposed to be doing?

Member Avatar for Lerner
0
148
Member Avatar for MrNoob

RVAs work like the segmented addresses. In the segmented memory model you have segments and offsets that combine to give the final address. An RVA is the offset that is combined to the PE's base address when loaded into memory. [QUOTE]what if there are many temperoralily variables wouldnt that overflow …

Member Avatar for MrNoob
0
479
Member Avatar for jupitertrooper

For the sake of not doing your homework, I will offer some advice only. The last character you will read on the line is '\n'. So if you read and ignore characters in a loop until '\n' is found, it will have the same effect as this call to ignore: …

Member Avatar for jupitertrooper
0
132
Member Avatar for ujjwalgoody2

[URL="http://www.daniweb.com/forums/announcement118-2.html"]The answer is...[/URL]

Member Avatar for Tom Gunn
0
150
Member Avatar for M Arifur Rahman

[QUOTE]In my book book there is a similar kind of problem where it's mentioned that the input value should be less than 32767.[/QUOTE] The range of [ICODE]signed int[/ICODE] is only assured to be at least[-32,767..+32,767]. If you want your code to be maximally portable, do not assume anything outside that …

Member Avatar for c coder
0
105
Member Avatar for alishujahx
Member Avatar for kranti_kumar38

It really depends on how your compiler implements the [ICODE]pack[/ICODE] pragma, but usually it packs on the lesser of the value given or the natural boundary for the type. There is no address boundary less than char, so no matter what argument you give to [ICODE]pack[/ICODE], it will use the …

Member Avatar for Tom Gunn
0
89
Member Avatar for stoymigo

[QUOTE]I have problems understanding the code quickly whenever I need to go back to it after some time.[/QUOTE] That is normal, and it is why code should be written as simply as possible without sacrificing functionality, and why comments that describe why you wrote something the way you did are …

Member Avatar for Ezzaral
-1
154
Member Avatar for Ponomous

[QUOTE][CODE]in_stream >> first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth;[/CODE][/QUOTE] Each variable should be separated by the extraction operator, not commas: [code] in_stream >> first >> second >> third >> fourth >> fifth >> sixth >> seventh >> eighth >> ninth >> tenth; [/code]

Member Avatar for Ponomous
0
132
Member Avatar for atch

[QUOTE]I have no idea for what I should use this (size_type) parameter.[/QUOTE] If your allocator does not need it, do not worry about it. The allocator interface was designed to be generic, and some allocators will need that information to manage the memory. For example, moving blocks from a 'used' …

Member Avatar for atch
0
93
Member Avatar for leoni

[QUOTE]in the first case: do I leave any garbage in the memory??[/QUOTE] Yes. You return a reference to a Vector, then use the copy constructor to make a copy of it in v. It causes a memory leak because you lose the reference. [QUOTE]in the secound case: I have to …

Member Avatar for leoni
0
147
Member Avatar for arshad115

[URL="http://support.microsoft.com/kb/311259"]This[/URL] might help, but I will caution you to remember that char and System::Char are not the same type. If you convert System::Char to char, there might be data loss depending on the contents of the string.

Member Avatar for arshad115
0
2K
Member Avatar for koban_alche

[QUOTE]What about portability?[/QUOTE] It is very hard to write useful, fully featured software that has no unportable parts. Knowing when and how to sacrifice portability in a way that benefits the application the most is one of the more important skills, I think. Too bad it is also one of …

Member Avatar for Tom Gunn
0
138
Member Avatar for Rabex

[QUOTE]A function to calculate factorials in math is a common example of recursion.[/QUOTE] [QUOTE]Linked list and binary tress use recursion [/QUOTE] [QUOTE]Here is a recursion that prints a message n number of time.[/QUOTE] All of these are pretty bad examples of recursion because they can be written with iteration and …

Member Avatar for mrnutty
0
200
Member Avatar for vileoxidation

In CPU.cpp, remove [ICODE]public[/ICODE] from all of the method definitions. C++ does not work like Java and C#, where the access level is applied to each entity.

Member Avatar for Grn Xtrm
0
190
Member Avatar for Vani3863

[QUOTE]I'm sure there must be a better way to write it.[/QUOTE] It looks OK to me. :) I only have one gripe, and it is a very small one: [QUOTE][CODE]for (int i = 1; i <= NR_ORDERS; i++)[/CODE][/QUOTE] The idiom for counted loops is an exclusive range of [0..N) instead …

Member Avatar for Tom Gunn
0
2K
Member Avatar for hmortensen

The seed for each thread is independent. You need to call srand() in the Draw() function to reseed for each thread.

Member Avatar for hmortensen
0
177
Member Avatar for marijn1

You tried it like this? [code] CopyFile(_T("\\svchost.exe","c:\\%windir%\\svchost.exe"), 0); [/code]

Member Avatar for Tom Gunn
0
382
Member Avatar for topsyturby

When you modify a variable more than once between [URL="http://en.wikipedia.org/wiki/Sequence_point"]sequence points[/URL], any result is possible. You have invoked [URL="http://en.wikipedia.org/wiki/Undefined_behavior"]undefined behavior[/URL].

Member Avatar for Tom Gunn
-1
358
Member Avatar for 54uydf

I do not recommend using pointer notation for indexing arrays if you do not have to. Array notation is easier to get right. Here is a sample you can use to compare with your code. Yours is very close: [code] #include <stdio.h> #include <stdlib.h> int Resize(int** list, size_t sz) { …

Member Avatar for manutm
0
113
Member Avatar for ulcimd1

[QUOTE]I know that it's a stretch, but I am looking for the third vulnerability in our practice program, and I can't find it.[/QUOTE] It's a big stretch. Even with the minimum range of int and no safeguards by the runtime, there would have to be 32,768 command line arguments to …

Member Avatar for Tom Gunn
0
116
Member Avatar for lancevo3

[QUOTE][CODE] if(p->data == "+") return op1 + op2; if(p->data == "-") return op1 - op2; if(p->data == "*") return op1 * op2; if(p->data == "/") return op1 / op2;[/CODE][/QUOTE] If none of these cases are true, there is no default return value, and execution will fall off the end of …

Member Avatar for sfuo
0
785
Member Avatar for EvanRG

The standard container classes will grow as you add to them, so there is no need to ask the user for how many inputs. You can even use a reverse iterator to go backward on most of the containers. [URL="http://en.wikipedia.org/wiki/Vector_%28C%2B%2B%29"]Here[/URL] is a start for research.

Member Avatar for Tom Gunn
0
149

The End.