Posts
 
Reputation
Joined
Last Seen
Ranked #153
Strength to Increase Rep
+11
Strength to Decrease Rep
-2
98% Quality Score
Upvotes Received
152
Posts with Upvotes
134
Upvoting Members
84
Downvotes Received
4
Posts with Downvotes
4
Downvoting Members
2
38 Commented Posts
~341.41K People Reached
About Me

Mathematical software developer

PC Specs
Windows 7 Visual Studio 2013
Favorite Tags

466 Posted Topics

Member Avatar for rajesanthu

I think that you should probably think about indenting your code a little, so that the various blocks are a bit easier to pick out. Also, I think that it's generally best to have [icode]main()[/icode] return [icode]int[/icode] rather than [icode]void[/icode], that way you can check the return value of the …

Member Avatar for Youssef Faisal
-4
44K
Member Avatar for marsh_mallows11

You have mixed up the way your variables are used in your functions. For instance you call [icode]toOctal[/icode] on line 19 without any arguments, but [icode]toOctal[/icode] take a [icode]long int[/icode] argument and the way they are used in the function will give you an infinite loop! The function [icode]toHex[/icode] also …

Member Avatar for Lesther_1
0
10K
Member Avatar for mahdi2592

Hmm, what you have shown here are three *functions* or *methods* from a class. Two of the methods are used in the setup of your output (`setOutputStream` and `setMessageCallback`) and the other (`outputMessage`) is used to actually output the things that you want to output. You haven't given much code …

Member Avatar for ravenous
0
313
Member Avatar for dyingatmidnight

[QUOTE=Tomi1988;1532016]I don't know. What is the solution?[/QUOTE] The solution is to write your own arbitrary precision integer version, which isn't as complicated as it sounds.

Member Avatar for Jimmy_7
0
213
Member Avatar for usingnamespace

> i thought of the boolean route but i dont know how to implement it. I cant even get the Part 1 to work Think about what are the biggest and smallest numbers that have six digits, all valid pass codes must be between these two values, right :)

Member Avatar for ravenous
0
253
Member Avatar for khaled02

I reckon that you'll get rid of some of your compilation errors by correcting lines like this: if (head == NULL >> tail == NULL) I think that you just want something like: if ( ! head && ! tail )

Member Avatar for khaled02
0
241
Member Avatar for norEdz

OK, you're current program is not going to do what you want it to at all. If I were you, I'd start by looking at the question more carefully and breaking it down into a number of small parts. So, the question is: [quote]write a c++ program that given the …

Member Avatar for David W
0
11K
Member Avatar for Ahmed91za

Use std algorithms where possible: #include <string> #include <algorithm> // Store the password in a string std::string password; /* Do things to get password from user */ // Count the upper and lower case letters size_t upper_case_count = std::count_if( password.cbegin(), password.cend(), std::isupper ); size_t lower_case_count = std::count_if( password.cbegin(), password.cend(), std::islower …

Member Avatar for ravenous
0
297
Member Avatar for can-mohan

There is a school of thought that says that you should not really design your class such that you're having to actually do things that could fail in the constructor. You should instead "inject" the things that the class needs directly into the constructor, which should simply be a thing …

Member Avatar for can-mohan
0
393
Member Avatar for Learner010

> `for(int i=0;i<10;std::cout<<i++<<std::endl); Yikes! Don't write code like this :) In general, tricks in code made code unreadable in the long-term. I think it's a reasonably good rule that one should *never* write a loop unless if can't be avoided. I have a hierachy of things that one should try …

Member Avatar for Markland
7
707
Member Avatar for MrXortex

You can do it with a single array and a single value of the type in the array (an `int` in your case). Use the single value as a temporary to swap the first and last elements and then the second and penultimate elements and so on. Or, you could …

Member Avatar for tinstaafl
0
467
Member Avatar for can-mohan

I agree with the comments so far that you probably need to explain what it is that you're trying to acheive when writing this code. All these raw pointers are generally not necessary in modern C++. Further to what Decepticon said about your assignment operator, your programm `main` looks like …

Member Avatar for can-mohan
0
437
Member Avatar for daniel1977

You want it to "work better" how, exactly? Are you looking for general code standards tips, hints on using more C++-like paradigms? etc...

Member Avatar for ravenous
0
170
Member Avatar for tentrabyte

You can check for even numbers using the `%` operator on an `int`: int even = 2, odd = 5; std::cout << "even: " << even % 2 << " odd: " << odd % 2 << std::endl; any even number will return 0 when you do `% 2` to …

Member Avatar for tentrabyte
0
310
Member Avatar for johans22

I notice that you're making a vector of vectors of doubles. Are you planning to use this like a matrix to do algebra on and such? Or, are there other constriants (all the "rows" have to be the same length, or something)? If these things are true, then you might …

Member Avatar for ravenous
0
299
Member Avatar for obinaysamanoden

Even broken up into individual little programs, I don't think these will even compile. Probably best to get them compiling first and go from there. Efficiency is not your biggest issue right now. If you don't know how to do that, then ask questions about the errors that occur when …

Member Avatar for David W
0
280
Member Avatar for manofprogram

You can open any file and access the bytes in it. However, making sense of those bytes is much more difficult in the case of something like an mp3 or jpg file. You'll probably want to use an external library for that...

Member Avatar for ravenous
0
98
Member Avatar for Fenrir370

I think that you need another `for` loop inside the `count` function, which will go over the array of random numbers and count each value. You should also use more descriptive names for the arguments to the `count` function; so `x` and `n` should be something more like `values` and …

Member Avatar for Fenrir370
0
255
Member Avatar for khess

I think that you could do something like point 2 using Zero Install, or something similar. Although, I'm not sure that I want things auto uninstalling! Zero Install might allow a more dynamic installation of programs (as well as a more traditional model). In regard to point five, I think …

Member Avatar for rubberman
0
701
Member Avatar for Vasthor

Hmm, I'm not sure what your original question is asking exactly. I do have some comments on your snippet though. 1. If you use `QList` to hold stuff, then the `QList` is actually holding pointers to the stuff for you. So, if own the objects in the list, then you …

Member Avatar for mike_2000_17
0
364
Member Avatar for Vivek_12

Just a comment, but if you have an array of strings, you can iterate through them with one of the std algorithms to count the ones that you want. So, to count the number of "hello" strings, you can simply do: auto number_of_hellos = std::count( S.cbegin(), S.cend(), "hello" ); It's …

Member Avatar for Vivek_12
0
465
Member Avatar for nathan.pavlovsky

What compiler are you using? It might be helpful if you posted the error message that you're getting (or at least the first couple of errors that you get) :)

Member Avatar for mike_2000_17
0
8K
Member Avatar for softwaretime

You can't do this: tmm += ("Minutes: " + tmm); th += ("Hours: " + th); `tmm` is an `int`. What would it mean to increment and `int` with the sum of a character array and an `int`?. There are probably a bunch of other things wrong with this code …

Member Avatar for frank.dekievit.50
1
13K
Member Avatar for runningirl
Member Avatar for dereje mulie
0
90
Member Avatar for chubbyy.putto

have you tried adding some debugging output to your code? For example, print out the value of the indices and values that you're trying to swap in that inner if statement...

Member Avatar for chubbyy.putto
0
260
Member Avatar for priya.chitroda

You've definitely created logic of sorts for doing the tasks in the question, but the logic isn't *encapsulated* in any functions. The question definitely says that you should write *functions* to add data to the class room's attributes, etc. Also, you should avoid the use of `goto` in your code---you …

Member Avatar for james.opdyckeii
0
128
Member Avatar for Labdabeta

I would say: - Don't use the macro version - Use the const int version if you plan to use the variables in arithmetic (your intentions are clear to the reader this way), I.e. if the numerical value of the thing is actually important to you. - Use the enum …

Member Avatar for Ancient Dragon
0
1K
Member Avatar for mrnutty

I was basically really hungry for most of my early twenties. My housemates noted this and started calling me Ravenous. It seemed like a cool user name so I use it wherever I can. It's actually kind of common, so I also use Ravenacious (which I don't think is a …

Member Avatar for Reverend Jim
0
687
Member Avatar for triumphost

Does something like this do what you want? std::uint32_t Checksum = 0; std::uint32_t CheckSum2 = 0; std::uint8_t* Ptr = Pixels; int K = Width < 12 ? 1 : 12; for (int I = 0; I < K; ++I) //Start at 0 offset { for (int J = 0; J …

Member Avatar for triumphost
0
885
Member Avatar for rajesanthu

who can help me when i shut down my window ,it show a massage which tell us .(waiting for background programme to close ).any advice would be appreciated .Thx all friend It's probably best to start a new thread if your question is totally unrelated to this thread, which your …

Member Avatar for Monu_1
-4
10K
Member Avatar for kubawpl

Your problem is on line 225 of `gen_map`. It's quite a subtle problem that is causing a stack corruption. You need to change `map_g[yt][xt][1] = 1;` to `map_g[yt][xt][0] = 1;`, there's only one unit of z-dimension, so you can't access element `1` in this dimension. The explanation of why you …

Member Avatar for ravenous
0
151
Member Avatar for chrispitt

> Inhertance is very good concept in c and c++. I don't think that C has inheritance, only C++. You can simulate a kind of inheritance in C, but it's not pretty and the compiler can't help you detect coding errors that you've made. Here's an example of inheritance in …

Member Avatar for ravenous
0
114
Member Avatar for gobiking

Same thing again. `sign != 'Q' || sign != 'q'` is *always* going to be `true`, you want ANDs there...

Member Avatar for Labdabeta
0
296
Member Avatar for alhaji.m.kanu

To get a better understanding, the task >b. write text to that binary file Does that mean that you have to read in the text file and then write the text into a new file, which is a binary file? Or, does it mean that you have a pre-existing binary …

Member Avatar for ravenous
0
186
Member Avatar for craig.durnin.1

>Once the results were calculated, it would then move to excel to show the results I think that you should try to move away from the idea that your program should *automatically* open Excel to display the results. There are a number of issues with this approach. For example, I …

Member Avatar for Ancient Dragon
0
2K
Member Avatar for Kangol

>This is what i have so far im new to this site This doe not appear to be C++. Do you have any C++ for this logic? If so, you should post that with some explanation as to what goes wrong when you try to build & run it.

Member Avatar for asifalizaman
0
214
Member Avatar for weasel7711

The best thing that you can do is to think of your own project. You can do basically anything in C++, so you have a wide range of areas that you can choose from. Some things are easier in C++ that others. I work in mathematical modelling, so I find …

Member Avatar for L7Sqr
0
299
Member Avatar for thats_nice

The [GNU Radio wiki](http://gnuradio.org/redmine/projects/gnuradio/wiki) has some documentation that might be useful to you.

Member Avatar for thats_nice
0
130
Member Avatar for robjackstewart

When printing out the array backwards, you don't need to read from the file again, since you've already stored the values in the array. You have also done something odd with the curly braces, so that I'm not sure that the loop is doing what you want it to. So, …

Member Avatar for ravenous
0
966
Member Avatar for sgw

> I tried to change the type to double, and print out without decimal part, it can deal with larger numbers than unsigned long. Maybe this is the best? `double` isn't magic though. A number like 100,000,000,000,000,000 (or 10^17) will not be represented *exactly* as a `double`. It will be …

Member Avatar for asifalizaman
0
256
Member Avatar for Nethran

From the image you posted, you've got a `std::bad_alloc` exception being thrown, which can't be a good thing. I'd find out where that's comming from. One possible source of that exception is that the loop isn't finding the node that you're asking for. If this means that you reach the …

Member Avatar for Nethran
0
396
Member Avatar for waqas.zafar.125

I think it means that the functions of `Set` should call the functions of `Vector` to do their tasks. For example: bool Set::IsEmpty() { return V->IsEmpty(); }

Member Avatar for rubberman
0
163
Member Avatar for anukavi

This is slightly confusing. I assume that `sizeof( BYTE )` is 1, but the value `0x9100` is at least two bytes big? Also, the size of `myKey[ 10 ]` is going to 10, so that isn't expressed by `0x9100` either. I think that you can do what you want to …

Member Avatar for ravenous
0
8K
Member Avatar for k_arjun

You have to be careful when using iterators to vectors. When you call `push_back` on line 59, the vector has to grow by one element. If the capacity of the vector isn't sufficient to hold the new element, then the vector will re-allocate memory to accomodate the new element. Since …

Member Avatar for k_arjun
0
242
Member Avatar for disjes

As mentioned by tinstaafl, you can do it `std::find_if`. To do this you will need a function that returns `true` when you hit the element that you want. Say your struct is called `A` and has a member `x`: struct A { int x; }; You need to define a …

Member Avatar for ravenous
0
152
Member Avatar for waqas.zafar.125

Are you allowed to use `std::string` and/or `std::vector`? If so, you can use `getline` to read each line into a `std::string` and add them to a `std::vector`: std::vector< std::string > grid; std::string line; while ( true ) { getline( file, line ); if ( line.empty() ) break; grid.push_back( line ); …

Member Avatar for ravenous
0
155
Member Avatar for kshahnazari

You could have some 'padding' around your array. So, use a 5-by-5 array instead of 3-by-3. Then, just ignore the values of the elements in the first and last rows and columns. Alternatively, you can have an array of pointers to updator functions that is the same size as you …

Member Avatar for ravenous
0
117
Member Avatar for can-mohan

>It's not leaking the old memory from s2. When the object goes out of scope, i.e. cannot be referenced or be reused in your program (or to be "revived"), the destructor is called automatically, thus freeing the memory of the s2 pointer. I'm afraid you have mis-understood how memory managerment …

Member Avatar for ravenous
0
273
Member Avatar for can-mohan

This doesn't work like you think it does. You never initialise the pointer `m_p` to anything. Also, on line 17 you leak the memory that you `new` on line 16. And I think that line 18 will the cause a stack corruption or segfault or something. Here's what your code …

Member Avatar for Lucaci Andrew
0
269
Member Avatar for spawn2004

I think that you should make a distinction between the question's ID and its number in the test. I would make the ID constant throughout the life of the question, but allow the number to change. You could do this by having a `GenerateQuiz` (or similar) function that goes through …

Member Avatar for Lucaci Andrew
0
192

The End.