556 Posted Topics
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: [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 … | |
Re: 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. | |
Re: 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. | |
Re: 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 … | |
| |
Re: 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. … | |
Re: [icode]for (j=0;j<2;i++)[/icode] 3rd expression increment j not i also you have mismatched braces countof { != countof } | |
Re: [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] | |
Re: 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 … | |
Re: 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 *. | |
Re: 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 … | |
Re: 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. | |
Re: |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 … | |
Re: Hard to tell without seeing the actual output and the desired output. | |
Re: 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 '\' | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: " 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] | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … ![]() | |
Re: 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. | |
Re: 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 … | |
Re: 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. … | |
Re: 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. | |
Re: 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 … | |
[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 … | |
Re: 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. | |
Re: 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] … | |
Re: 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 … | |
Re: 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 | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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? | |
Re: 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 … | |
Re: @coded_hitec I believe the answer to your question is "no" but I would be happy to be corrected. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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 … |
The End.