1,288 Posted Topics

Member Avatar for lee.martin.568847

`cout << "Scores = " << score << endl;` score is (effectively) a pointer. Your code will output a hexadecimal address. I expect you want to output each score. for (int i=0; i<7; i++) { cout << score[i] << " "; } Also, this: `for (unsigned int i=0, Total=0;` create …

Member Avatar for lee.martin.568847
0
1K
Member Avatar for Drgy55

Give us a sample input and the output you get. We don't know what value temp begins with. We don't know what kind of objects the variables are. We need the code that goes around this.

Member Avatar for Moschops
0
279
Member Avatar for hamsa.mohd

This is simple geometry that you could have worked out by playing with circles on a piece of paper. Programming is THINKING first and foremost. Calculate the distance between the two central points (see Pythagoras' theorem). If that distance is more than the sum of the two radii, they do …

Member Avatar for Moschops
0
82
Member Avatar for Suzie999

On the assumption that you're intending to use this on Win32 executables, it sounds like you want to know about the internal structure of a Win32 executable. Start here: http://en.wikipedia.org/wiki/Portable_Executable and then follow the references.

Member Avatar for Moschops
0
167
Member Avatar for SpottyBlue

Think about what you're going to code. Identify the first thing your code will do. For example, you might decide to start by getting a four digit number from the user. Code that. Code as far as you can and then come back with your code and ask us about …

Member Avatar for Moschops
0
505
Member Avatar for bazingatheory

Given that we can't see your new line 18 or the code around it, you're going to have to show us the code again.

Member Avatar for Moschops
0
352
Member Avatar for alxanderajon

if (firstNumber is smaller than second number) { if (firstNumber is smaller than third number) { // firstNumber is the smallest. Do something } }

Member Avatar for rubberman
0
94
Member Avatar for gobiking

> The issue I am having right now is my program is not running unless I give my add, sub, etc. a value. When I try to just leave them as int add; or int sub; It will not do the equation. Yes it will. You'll get some random value …

Member Avatar for gobiking
0
226
Member Avatar for MRehanQadri

Please rephrase the question. Make sure you include the following things: 1) What you're trying to do. 2) What the error is (which means tell us what your compiler error is; the exact words, all of them). 3) The code. Do NOT put your code on another site in a …

Member Avatar for MRehanQadri
0
187
Member Avatar for Shahrukh017

If you means stopping someone doing something like this: someClass pleaseDoNotCopyMe; someClass IwantToCopy; IwantToCopy = pleaseDoNotCopyMe; // Forbid this someClass anotherCopy(pleaseDoNotCopyMe); // Also forbid this you can make a private assignment operator and copy constructor private: someClass (const someClass & theOneToCopy); // no body - forbid copy construction someClass & …

Member Avatar for Moschops
0
112
Member Avatar for Labdabeta

CImg is one I often point people at. It's very easy to use; a single header file. It meets some of your needs very well, others less so, but by virtue of being a single header file it has a good stab at being cross-platform and not so reliant on …

Member Avatar for Labdabeta
0
239
Member Avatar for dancks

Very commonly, this sort of thing is because there is something left over in the input buffer. Often a '\n' or other such. If you're going to mix scanf and fgets, you need to flush the input buffer after use. This sort of thing: http://stackoverflow.com/questions/2907062/fgets-instructions-gets-skipped-why

Member Avatar for dancks
0
134
Member Avatar for kamalashraf

Look at the first digit. Check if it is less than two. Look at the next digit. Check if it is less than two. Repeat for all digits. I suggest you get the number as a C++ string, and examine each char in the string using the [] operator.

Member Avatar for Banfa
0
543
Member Avatar for tensity

> I am trying to understand what I did wrong? find does not return 0 when it doesn't find what it's looking for. It returns string::npos

Member Avatar for Moschops
0
116
Member Avatar for yankeetooter7

Look at first character. If it's not a letter, then there is at least one character that is not a letter. Stop now. If it is a letter, move on to next character. Next character: Look at it. If it's not a letter, then there is at least one character …

Member Avatar for yankeetooter7
0
208
Member Avatar for kshahnazari

`a[i]` is an object of type heapnode. `mininfinitive` looks like a long. You have not taught the compiler what the operator = means when you use it with a heapnode and a long. What are you expecting to happen? It makes no sense to say that a heapnode object (which …

Member Avatar for Moschops
0
262
Member Avatar for amjadalibooni

Are you supposed to be writing code to perform the operation, or are you just supposed to be writing a regular expression, or are you supposed to be writing code containing a regular expression which then calls some kind of library function that processes regular expressions?

Member Avatar for Moschops
0
88
Member Avatar for TarkiB

Every time you call `new`, you allocate some memory on the heap. Your function memLeak does this twenty times. When the function ends, all the pointers to that memory (the pointers named data1 to data20) are destroyed. The memory is still allocated. You have no way to `delete` it because …

Member Avatar for mike_2000_17
0
379
Member Avatar for Lakhan Thakur

No matter how tempted, do not read anything about pointers that invites you to think of them as house numbers written on paper, or pigeons, or telephone exchanges, or any other distracting, broken analogy :)

Member Avatar for Moschops
0
169
Member Avatar for adison.afonso
Member Avatar for biepie70

You ask your operating system to show graphics on screen, using your operating systems provided libraries. You can either do it directly yourself, or you can get another set of libraries to do it for you, and you ask those libraries. C++ specifies nothing about graphics. It's all dependent on …

Member Avatar for owenransen
0
94
Member Avatar for Suzie999

Somewhere in your code you are calling a function with some bad values, and that function probably calls another, and another, and so on, until finally the function that has to deal with those bad values discovers they're bad. If you build with debugging symbols on, the error should present …

Member Avatar for Suzie999
0
378
Member Avatar for liphoso

It's not a C++ error; it's an SQL error. Get the C++ to spit out the complete query being sent so you know for sure what it's sending, and then find the error in it.

Member Avatar for gusano79
0
171
Member Avatar for shanki himanshu

> my main problem is how to get the length of the two arrays? Our main problem is that we don't know the whole question.

Member Avatar for shanki himanshu
0
379
Member Avatar for kyle.mace.35

> In Event my second constructor gets an error saying expected initializer. Would that be this code? Event::Event(int a, int b) Event::Event(int a, int b) { ArrivalTime = a; wait = b; } Looks like it says `Event::Event(int a, int b)` twice.

Member Avatar for kyle.mace.35
0
161
Member Avatar for Bchandaria

How would you do it on paper? Programming is problem solving. What's the simple pattern here that tells you what to write on every line?

Member Avatar for Moschops
0
110
Member Avatar for MareoRaft
Member Avatar for MareoRaft

This is broken in two different ways. Firstly, you are using a single char (i.e. one byte only) to try to store all the user input. This is bad. You will trash memory. You need to read up on what a c-string is (i.e. an array of char) and how …

Member Avatar for Moschops
0
140
Member Avatar for solomon_13000

In C (and C++) part of the language design doctrine is that you shouldn't have to pay for what you don't use. If you don't want to use exceptions, you shouldn't have to. You, the programmer, are trusted to know what you're doing and the choice of using exceptions or …

Member Avatar for mike_2000_17
0
228
Member Avatar for boris90

You'd get a better response on a .NET/Managed C++ forum - this is a C++ forum and whilst some C++ coders are also familiar with .NET and managed C++ and all that, many are not.

Member Avatar for boris90
0
437
Member Avatar for tyler.dahle

Many ways. Here's one. Make the projectile a different object completely. Upon creation, it copies its location from the player. After that, it's completely independent.

Member Avatar for tyler.dahle
0
166
Member Avatar for Griff0527

`while (readFile >> a[i])` Every time you try to write to the vector like this, you have to be sure that the element `a[i]` exists. Given that at the start, the vector is of size zero, this is not going to go well. You're trying to write to a part …

Member Avatar for Griff0527
0
534
Member Avatar for MasterHacker110
Member Avatar for nmakes

How much space have you allocated for the string `a`? What happens if `a` can hold, say, four characters, and then you try to write an extra 10 characters from `b` after the end of it? Something bad happens. Don't forget to allow for such things. Let's ignore that for …

Member Avatar for nmakes
0
196
Member Avatar for buug

In the future, you'd do better to show us all the code. This code, for example, doesn't contain the **main** function, so we have no idea where your code starts executing and we don't even know if your code even calls the functions you've shown.

Member Avatar for buug
0
133
Member Avatar for NguyenHgLong

Someone has created some (probably hideous) macros, FUNCTION and TYPE, which get applied to this code. Find them and see what they do, and your questions will be answered. If I had to guess, whoever first coded this was more comfortable in some other programming language and decided to use …

Member Avatar for Moschops
0
119
Member Avatar for nick.rechtien.5

Your loops make no sense. You ask the user to enter a value into the variable `name` which you immediately write over from file. You have a `while` loop that you break out of on the first time round. This code: if (!inputFile) { cout << "Animal not found."; } …

Member Avatar for nick.rechtien.5
0
282
Member Avatar for ryl294

First one's free. double Input(double TimeEnd, double TimeStart, double BasicPay) { double totalPayment; if (TimeStart>=1&&TimeEnd<=7) { totalPayment=(TimeEnd-TimeStart)*1.20; } else {double basicPay=(7-TimeStart)*1.20; double overTime=(TimeEnd-7)*1.75; totalPayment=BasicPay+overTime; } return totalPayment; }

Member Avatar for Moschops
-2
257
Member Avatar for saurabh.mehta.33234

You are allowed to redefine a variable inside a deeper scope. This is commonly called "shadowing" and it's generally regarded as a bad idea.

Member Avatar for Moschops
-1
110
Member Avatar for tanmay.majumdar2

tanmay exists INSIDE your do-while loop, but you're trying to check for it being open OUTSIDE `while(!tanmay.is_open());` Also, you're using a very old C++ compiler and not doing yourself any favours. You can get a new, modern one for free.

Member Avatar for vmanes
0
142
Member Avatar for nova37

> bpath is char and have C:\myf\myapp.exe If you mean bpath is a char-pointer try `C:/myf/myapp.exe` instead. The `\` is an escape symbol but `/` is recognised as the directory delimiter under windows and *nix.

Member Avatar for untio
0
251
Member Avatar for saurabh.mehta.33234

> But how does the 32767 come..? It's made of whatever random values happen to be in that memory. You're reading memory you never set to a value, so it could have anything in. If your code above is the whole program, it's just whatever was left in that memory …

Member Avatar for saurabh.mehta.33234
-1
125
Member Avatar for mical700

This is supposed to be written in C? The following lines of code are C++ and need to be replaced with C code. #include<iostream> #include<fstream> #include<string> using namespace std; string filename; fstream fin; cout<<"Enter a filename"< cin>>filename; fin.open(filename,ios::in); cout<<"Error while opening file "< fin.get() cout< cout<<<"------------------------------"< cout<<"ENTIRE FILE HAS BEEN …

Member Avatar for deceptikon
0
1K
Member Avatar for Learningvinit
Member Avatar for shawn.main.7

> 'calculateGrade' : must **return** a value what do I have wrong as I'm not seeing it. See how your function `getScore` uses **return** to return a value? Where is the return value from `calculateGrade`? The instructions tell you to *return the course grade*

Member Avatar for deltascrow
0
635
Member Avatar for malloju

"Undefined reference" means the linker cannot find the actual function code. Generally, this means that you have not linked against the right library, or that you simply haven't written the code (and sometimes that you've spelled the name of a function incorrectly). Unless the actual code of the function is …

Member Avatar for Moschops
0
145
Member Avatar for tomz6

By definition the byte is the smallest size object that can be addressed, so you have to read the whole byte and work with that. Off the top of my head, I can't think of anything likely to be faster than the simple and obvious approach, particularly if the compiler …

Member Avatar for RonalBertogi
0
255
Member Avatar for Mbokodvo

Every time you make something that runs in Code Blocks, you've also made an exe file that does the exact same thing. That's what's running. Just find that exe file and run it.

Member Avatar for ddanbe
0
285
Member Avatar for NikkiStars

These sound like things specific to your programming class. I've no idea precisely what's meant by "program analysis" but you probably won't be going far wrong if you identify the input from the user, the calculation to be done on the input, and the returned information to be displayed to …

Member Avatar for NikkiStars
0
335
Member Avatar for tyler.dahle

Readiing the images from file is probably taking ages. You would do better to read them all beforehand and store in memory.

Member Avatar for tyler.dahle
0
199

The End.