556 Posted Topics

Member Avatar for sanagopi

What you also need to be aware of is that right shift of a signed value in C is a platform defined operation and may be either arithmetic shift or logical shift. That means the the operation [code]-2 >> 1[/code] is not truely portable because the result could be either …

Member Avatar for Banfa
0
2K
Member Avatar for EricM3

I think you will find this easier to do if you start-up a worker thread to perform your "process" leaving the original thread running the user interface. My C++/CLR is quite rusty but I think you could use a delegate to call back to the interface thread with process updates …

Member Avatar for EricM3
0
228
Member Avatar for Sandhya212

As always with programs when you have a problem with your command line arguments put them in quotes [icode]-D"COMPLEX=std::complex<double>"[/icode] I imagine that the command line interpreter is < as the input piping operator.

Member Avatar for Sandhya212
0
563
Member Avatar for gtschemer

[QUOTE=gtschemer]Unfortunately, some brief searching has left me uneasy about whether C++ really guarantees that all pointers to objects (i.e. SomeClass) and primitives (i.e. long int, char, etc.) will be the same size.[/QUOTE]I would have thought (I don't have my standard to hand to check) that C++ makes the same guarantees …

Member Avatar for Banfa
0
129
Member Avatar for iwanttolearnc

You might try having a look on [url]http://www.zilog.com/[/url] and not the the header file is unlikely to be any use without the accompanying binary library.

Member Avatar for iwanttolearnc
0
156
Member Avatar for Fr33t

Line 43 and 44, you copy to the char pointers fname and lname but you have not allocated any data for those pointers to point to. They are uninitialised.

Member Avatar for Banfa
0
223
Member Avatar for xaop

The compiler probably doesn't crash after entering c because the compiler never requests that you enter c. Presumably you are actually running the program to get to the enter c phase. The program doesn't crash either, it does what you have asked and exits normally (or it does for me …

Member Avatar for abhimanipal
0
134
Member Avatar for joe_adelmo
Member Avatar for darkdai

Line 9 info[i].qt1 is an array, you can't perform assignment or most mathematical operations on an array. The expression info[i].qt1 returns a pointer to the first element of the array and the code tries to add that to info[j].sal_amount which is a float and so this is an illegal operation. …

Member Avatar for abhimanipal
0
97
Member Avatar for Xufyan

[icode]for (j=0;j<2;i++)[/icode] 3rd expression increment j not i also you have mismatched braces countof { != countof }

Member Avatar for Xufyan
0
172
Member Avatar for farhanafzal

[QUOTE=farhanafzal]i have red in my lectures, that the following code [CODE]m-=m*3-h++*2;[/CODE] can also be written as [CODE]m=m-m*3-h++*2;[/CODE][/QUOTE]No [ICODE]m-=m*3-h++*2;[/ICODE] can be written as [ICODE]m=m-(m*3-h++*2);[/ICODE] Those parentheses make all the difference because when you factor them out it becomes [ICODE]m=m-m*3+h++*2;[/ICODE] Which is different to [ICODE]m=m-m*3-h++*2;[/ICODE]

Member Avatar for nbaztec
0
232
Member Avatar for Swiftle

Have you heard of the placement new syntax? Placement new constructs a new object without allocating memory for it. You have to provide the buffer yourself. [code] char *buf = <allocate data in you onw method>; Elem* normal = new Elem(0 NULL); // Normal new call allocates data from heap …

Member Avatar for nbaztec
0
156
Member Avatar for John Linux

That is not a very easy macro definition to demonstrate the other error but consider this code using that macro [icode]~SQR(2)[/icode]. What do expect the output to be, what is it? This is normally more easily demonstrated with the macro in question uses + rather than *.

Member Avatar for Banfa
0
86
Member Avatar for etisermars

p does not point to any ClsA objects, p points to a pointer to ClsA objects. A pointer is a built in type and has no constructor or destructor. So no destructor call is required for that delete statement. Presumably in the code lines 21-22 you have something that does …

Member Avatar for mbulow
0
139
Member Avatar for caut_baia

Is there any alternative to polling to do what? For example in communications there is often an alternative to get the system to tell you when there is data waiting rather than polling for it.

Member Avatar for Banfa
-1
151
Member Avatar for sdinu96

|That is because *n is a char and 275 is larger than a char. You need to cast to a pointer to int so that you are storing an actual integer. However I would strongly discourage this whole code structure, directly accessing the byte of members of a structure through …

Member Avatar for Banfa
0
465
Member Avatar for maryam ahmad
Member Avatar for maryam ahmad
-1
142
Member Avatar for myth_terry

That is because \ is the escape character in string literals in C (and C++) so '\t' is a tab character and '\p' is p (I think). To get an actual slash you need '\'

Member Avatar for myth_terry
-3
218
Member Avatar for keeda

You have 2 C++ files, test.cc and classclock.cc The problem you highlighted in post 1 is at the link stage and is because you have compiled and linked test.cc maybe like this g++ test.cc what you need to do is compile test.cc, compile classclock.cc and link the output of the …

Member Avatar for mitrmkar
0
82
Member Avatar for kavourdoukos

Line 49 does not have the same separators as line 28 It is no good just saying it wasn't successful, we do not know what it was meant to do or what it actually did unless you tell us.

Member Avatar for abhimanipal
0
116
Member Avatar for dfetter88

Well you can look for a correlation between the size of the item the calculation is dependent on (data size) and the resultant size of the calculation, which could in fact be any column. However your run time column is clearly useless as it does not have the resolution to …

Member Avatar for Banfa
0
123
Member Avatar for elexender

" is a special character as it delimits the string. If you want a " in your string you need to escape it using \ so the compiler treats it as a character in the string and not a string delimiter like this [icode]"\""[/icode]

Member Avatar for elexender
0
106
Member Avatar for priyarao

In your load function you call fgetc, that gets a single character from the file so for a number like say 10 it returns '1' which has the value 49. You then make a node out of the value 49 and continue making nodes out of every character in the …

Member Avatar for technology
0
121
Member Avatar for sdinu96

OK you CAN assign a structure pointer to a char point but it is not a terribly good idea and doesn't serve any good purpose on the whole. On your malloc line you assign a value to n, it points at some allocated data. Then on the next line you …

Member Avatar for Banfa
0
98
Member Avatar for Ja14

Your logic in your first code listing just will not work. For example [icode]for(int r = 0; r < numRows; r++)[/icode] you use numRows as the loop limit, but numRows is what you are trying to calculate. What will be its value the first time the loop is entered? 0 …

Member Avatar for Ja14
0
130
Member Avatar for ssmg

If they have input only integer data then all there should be is a string of digits. [list=1]So get you get a line of input [*]Extract an integer from it [*]Verify the rest of the line is blank [/list] If either step 2 fails or the rest of the line …

Member Avatar for hypernova
0
432
Member Avatar for randy03

You are looking for the @ and printing the address as soon as you have found it. What you need to do is count the number of @ in the string then once the loop has finished if and only if you have exactly 1 @ print the address. It …

Member Avatar for iamthwee
0
2K
Member Avatar for karuppg

I didn't think nmake did automatic detection of dependencies which means you will have to edit your make file(s) and manual type in you dependencies.

Member Avatar for Banfa
0
252
Member Avatar for m-lamaa

When you have sent the HTTP request the data returned to you will be some headers followed by the contents of your page. It will all be text and for now you can probably treat it as ASCII encoded text although strictly speaking HTTP can use a wide variety of …

Member Avatar for siddhant3s
0
145
Member Avatar for bobsta

It sounds to me like you are making a design mistake. You shouldn't be permanently storing iterators you should create them when you need them they are essentially a temporary thing. There is a good reason for this, for several of the containers under certain operations iterators can become invalid. …

Member Avatar for Banfa
0
288
Member Avatar for westsider123

Instead of outputting every time you find a prime factor you need to increment a count of the number of times you have had that prime factor. Then when you find a new prime factor output the data for the previous prime factor.

Member Avatar for jephthah
0
427
Member Avatar for jephthah

I can live with the colour scheme, I personally like purple and I can live with the changed layout or get used to it. What is a pain is the drop in functionality of the main links. What was Today's Posts --- C++ --- Software Development --- My Subscribe Forums …

Member Avatar for Dani
8
2K
Member Avatar for Banfa

[QUOTE]This discussion has been moved from [url]http://www.daniweb.com/forums/thread284115.html[/url]. Check there for the beginning.[/QUOTE] = = = = = = = = = = = = = = = = = = = = Actually neither approach is wrong. The original code does not store prime numbers but does correctly identify all …

Member Avatar for 0x69
3
308
Member Avatar for theABCasian

A memory leak normally involves actually allocating memory and then forgetting to delete it. Since I see no allocations I fail to see how you could be leaking memory. Tell us what actual errors you are getting.

Member Avatar for Ketsuekiame
0
268
Member Avatar for freemanirl

You shouldn't just output rgValue, it is binary data unless Type has a value of REG_EXPAND_SZ, REG_MULTI_SZ, REG_SZ. If the value in the registry is really a DWORD then Type should be REG_DWORD and size1 should be 4 on exit. In that case something (non-portable) like [icode]DWORD dwValue = *((DWORD*)rgValue);[/icode] …

Member Avatar for freemanirl
0
203
Member Avatar for corby

tests and RunExperiment are both members of Experiment so RunExperiment can access tests directly even though tests is private since this only stops access externally to the class. tests is an array of pointers [icode]Test *tests[maxTests][/icode] so tests[0] has type Test* so to access the member of Test you would …

Member Avatar for corby
0
126
Member Avatar for rohitn

There is no standard way to do this you will need to check your operating system library manuals. In the WIN32 API there is [url=http://msdn.microsoft.com/en-us/library/aa363855%28VS.85%29.aspx]CreateDirectory[/url], however Linux will use something different as would .NET

Member Avatar for Banfa
0
90
Member Avatar for inisca

You can use [url=http://msdn.microsoft.com/en-us/library/aa909766.aspx]PlaySound[/url] to playback a wav file. The actual contents can be a little complex because the data can be encoded in a number of different ways including mp3. However in its simplest form PCM it is actually very simple has it consists of an simple array of …

Member Avatar for Banfa
0
93
Member Avatar for NathanOliver

I am not convinced by this solution for instance line 17 can be replaced by [code] number /= i; i -= 2; [/code] which seems rather simpler and less wasteful of stack space. The whole point of recursion, in my opinion is to remove iteration (loops) so way recursive function …

Member Avatar for NathanOliver
0
134
Member Avatar for clement99

Your input operator >> is not correctly parsing the input data. To start with what if someone types a space before the equation, accessing the characters by direct offset is almost bound to cause an input error at some time. What if one of the numbers has more than a …

Member Avatar for Banfa
0
176
Member Avatar for Iam3R

why would -1 be converted to unsigned int when [icode](unsigned char) 1[/icode] can just be converted to int which has more width than unsigned char and is already the type of -1? Did you mean to compare -1 and 1U?

Member Avatar for Iam3R
0
121
Member Avatar for etisermars

For built in types you can not do this. I suppose that you could create a class that referenced another value and used that as a basis to calculated the "value" of the class. However that would probably be very confusing to anyone reading your code and rather hard to …

Member Avatar for Banfa
0
114
Member Avatar for coded_hitec

@coded_hitec I believe the answer to your question is "no" but I would be happy to be corrected.

Member Avatar for coded_hitec
0
111
Member Avatar for gregarion

Both lines 6 and 29 should definitely not have the void type, constructors do not have types. The reason your output stream handler doesn't show the input is that the input stream handler writes to LineA but the output stream handler outputs valuea. Nothing in the called code converts what …

Member Avatar for jonsca
0
121
Member Avatar for Xorlium

It should never be considered "safe" to cast away a const, on some platforms const values are actually stored in constant unchangeable memory and trying to alter such a value can produce a processor trap. In fact I can not think of a time when casting away the cost is …

Member Avatar for Xorlium
0
172
Member Avatar for hr1212s

Basically you can resolve without using a pointer because a pointer (or reference) is the only thing you can declare in the presence of an incomplete type and either X or Y must be incomplete at the time the other is declared. Any reason you don't want to use a …

Member Avatar for Banfa
0
63
Member Avatar for aloush91

If you have a fixed range to find prime numbers over, as in your case all primes below 100 another method is to create a list of all the numbers, 3,5,7,...97,99. Then you take each entry in the list in turn and remove all multiples of that value from the …

Member Avatar for Banfa
0
177
Member Avatar for etisermars

No [b]YOU[/b] are wrong, that is not 2 variables at the same address, that is a variable and a reference to the same variable. A reference is not a variable. You can not have 2 variables at the same address, the standard specifically mandates against this. You can not change …

Member Avatar for Fbody
0
3K
Member Avatar for xofth

You never call the constructor that takes parameters with "mark" "australian". You never call the [icode]display()[/icode] method Does it even compile? main returns int not void returning void is undefined behaviour.

Member Avatar for needhelp//
0
74
Member Avatar for nath.sai1234

The standard splits all expressions into 2 broad categories, lvalue and rvalue. The actual definition with-in the standard is rather involved but a simplistic rule of thumb is that an lvalue is an expression that results in a modifiable value where as an rvalue doesn't. Any lvalue can be converted …

Member Avatar for Banfa
-1
105

The End.