166 Posted Topics

Member Avatar for Na'Vi

Can you provide us with the code you have for the `registers()` function? Perhaps the reason you're getting an extra percent sign is because your function is tacking it on automatically. If it's not, I would have a reason to believe there's something wrong with your compiler because when I …

Member Avatar for nullptr
0
154
Member Avatar for lewashby

`argv` is not a `char`, it's a pointer to a pointer to a `char`, so the comparison `argv != '\0'` makes no sense. You really shouldn't be modifying `argv` directly by incrementing it anyway.

Member Avatar for Suzie999
0
164
Member Avatar for pars99

The physics engine is actually the easiest thing you can possibly do when designing a 2D game like you describe, especially if the framework of the game engine is written in such a way that time is cut up into "ticks" and the physics updates on each of these ticks …

Member Avatar for Tumlee
0
839
Member Avatar for J-P1988

You forgot to post Personnage.h so we might not be able to help you troubleshoot your problem. Can you at least tell us *which* variables it's complaining about being undefined?

Member Avatar for J-P1988
0
6K
Member Avatar for gunjan.vora.9

> Where am I going wrong? If you had given your variables descriptive names so you could easily read through what your code is doing, or at least provided comments illuding to your train of thought when writing this program, you likely wouldn't have to ask us this question.

Member Avatar for Tumlee
0
153
Member Avatar for nah094020

On line 43, `while(stillguessing == true);` you have actually results in an infinite loop if `stillguessing` is true, because of the semicolon. Remove the semicolon to fix it.

Member Avatar for Ancient Dragon
0
157
Member Avatar for saurabh.mehta.33234

In the case that you've presented here, `sizeof(a)` is resolved during compile. The only time it's resolved during runtime is when you're dealing with C99's variable length arrays. The reason the above code works is that the number of bytes taken up by an `int` is always going to be …

Member Avatar for deceptikon
0
397
Member Avatar for abbashadwan

> That was a valid program, if written 30 years ago. If by "valid", you mean "it compiles". The `void main()` means it's techincally not legal C++. > You must use either std::cout or issue the following statement before using cout: using namespace std; I personally use like to include …

Member Avatar for Ancient Dragon
0
232
Member Avatar for pinkesh25gar

You'll have to write code manually that will sort the array. You can use Google to find various sorting algorithms you can use.

Member Avatar for Ancient Dragon
0
275
Member Avatar for shanki himanshu

> thats why i am using memset which fails. This isn't what `memset()` is supposed to be used for. It does byte-by-byte setting to a specific value. You're going to have to use the loop.

Member Avatar for Tumlee
0
548
Member Avatar for mayankjain05

More than likely, your program will terminate immediately. Sometimes it will keep going, overwriting memory that you're not supposed to will almost certainly cause your program to malfunction somewhere later. My advice is that you're not supposed to do it.

Member Avatar for mayankjain05
0
109
Member Avatar for hust921

In the future, if you have a new question you should create a new thread. Otherwise, people will skip over your thread thinking it's solved. The crash is located on the line where you call `fclose(fpOUT)`. Upon further inspection, it appears that you never actually open `fpOUT` so why it's …

Member Avatar for hust921
0
233
Member Avatar for lewashby

There is no difference, functionality-wise between `char** argv` and `char* argv[]`. It's all a matter of preference.

Member Avatar for Lerner
0
128
Member Avatar for deceptikon

Uniform initialization refers to this, correct? class xypoint { public: float x; float y; xypoint(float xx, float yy) : x{xx}, y{yy} { } }; xypoint returnpoint(void) { //Equivalent to "return xypoint(3, 4);" return {3, 4}; } I don't see what's so controversial about it. To me, it just looks like …

Member Avatar for vijayan121
0
429
Member Avatar for mattboy64

Clarifying what Adak said, here's what you should know: The & symbol (address-of operator) will return the address of a variable (where it is stored in memory). If you have declared an integer called `foo`, then `&foo` would be its address. When you're dealing with`printf()`, you only really need to …

Member Avatar for Tumlee
0
184
Member Avatar for Vasthor

When you're using range-based for loops, the variable you declare to the left of the colon must be at type that refers to an element of the array or list on the left. Take the following code: #include <iostream> using std::cout; using std::endl; int main() { int array[4]; for(int& element …

Member Avatar for Tumlee
0
941
Member Avatar for anestistsoukalis

We would have to get a copy of what file you're working with to even begin to understand what your problem is.

Member Avatar for tinstaafl
0
226
Member Avatar for saurabh.mehta.33234

I reccommend nullptr's suggestion. You're going to have to get used to the double percent sign anyway, because there are some situations where you need to have both a format specifier *and* a percent sign in the same call to `printf()`. printf("Jimmy got a %d%% on his quiz!", percentage);

Member Avatar for Gonbe
0
157
Member Avatar for tiggermesho

You're trying to grab the lowest five values in your array, right? What would really help you is if you commented your code, so you're forced to explain your thought process to yourself. That way, it will become more obvious why your code doesn't work. The reason your program is …

Member Avatar for jalpesh_007
1
235
Member Avatar for pianokey09

> Not possible. Line 27 is wrong, as I explained in my last post. open() doesn't take a std::string as the first argument, it takes only char*. Perhaps he's using some old or otherwise nonstandard compiler that's somehow automatically typecasting `std::string` to `const char*`?

Member Avatar for Ancient Dragon
0
156
Member Avatar for doug.leany

What you're probably looking for this the pre/post build steps tab under your project's `Build Options...` menu, which will allow you to set certain scripts to be executed whenever you build your project. Go to `Project` > `Build Options...` and then go to the tab that says `Pre/Post build steps`.

Member Avatar for doug.leany
0
379
Member Avatar for vishalonne

When you're using macros like this, please pay attention to exactly what the code looks like when your macro is expanded. The code you have here is equivalent to writing the following: #include <stdio.h> #include <conio.h> void main() { int i=5; int j=for(typeof(i) i=2; i<=n; i++){f *= i}; printf("%d",j); getch(); …

Member Avatar for Tumlee
0
137
Member Avatar for Sasquadge

The only thing you'll need to do here is to reset `total` to zero at the beginning of your loop. That action alone will fix your code. > You're missing a few brackets and others aren't correctly placed. There are no missing brackets here, and the brackets aren't placed incorrectly …

Member Avatar for Prysm[VA]
0
172
Member Avatar for Xmod

That code uses old, nonstandard functions like `kbhit()` and `gotoxy()`, which are functions that you'll hardly ever see outside of ancient compilers like Turbo C++ for DOS. Your best bet for ever getting this to work is trying to find curses.h on Google, and I'm not even sure if that …

Member Avatar for vijayan121
0
479
Member Avatar for billionair

Unfortunately, it would have to be even more complicated that that. You have to be able to intelligently ignore `//` when it occurs in quotes, otherwise, you would end up cutting strings apart. Take the following code, for example: #include <stdio.h> int main(void) { printf("I like to // eat apples.\n"); …

Member Avatar for deceptikon
0
1K
Member Avatar for batman189
Member Avatar for NP-complete
0
143
Member Avatar for UNDER-18 FG

Here's how I comment your code. Please note that, according to your code, 2 is not a prime number. You might want to fix that. import java.util.Scanner; //This line helps the compiler find the class file Scanner. public class PrimeNumber{ //Defines a class called PrimeNumber public static void main(String args[]){ …

Member Avatar for JamesCherrill
0
293
Member Avatar for aramil daern

I know what the OP is talking about, I have dealt with some pretty nasty code in my time. I think weird problems like always-true loop conditions that only execute once, etc. are rare problems though and they're much easier to fix. I once took a venture into the Doom …

Member Avatar for Echo89
1
485
Member Avatar for prakhs

We're not going to go through your entire program, line by line, and figure out what's wrong with it. Unless you tell us what problem you're having and where, there's no point in 'debugging' it.

Member Avatar for prakhs
0
164
Member Avatar for samii1017

Sevaral problems here: **1)** You're using `charChoice` as an index for accessing your `charArray[]` array. The character `'c'` is equal to 99, so you're always just overwriting the last element of your array. **2)** You successfully save the character that the user types into `charArray[charChoice]`, but then your `for` loops …

Member Avatar for faroukmuhammad
0
918
Member Avatar for xikhari.some1behindu

The reason your program is behaving so unpredictably is because you are not initializing the variable `res` in your `seno()` function, nor are you initializing `sin1` in your `sen()` function. Because you are using the values of these variables before initializing them, you are invoking undefined behavior. I could go …

Member Avatar for xikhari.some1behindu
0
271
Member Avatar for Carc369

The reason it's skipping is becuase `char` is actually a *signed* type, which means that it includes positive and negative numbers. This means that, when trying to interperet a `char` as an 8-bit integer, its effective value range is actually -128 to 127 instead of 0 to 255. When a …

Member Avatar for Carc369
0
161
Member Avatar for pennywise134

When you have two functions of the same name that take a different list of parameters, this is called overloading a function. When you do this sort of thing on a class constructor function, it is callled an overloaded constructor. Your default constructor is the class constructor that you define …

Member Avatar for starpro57
0
151
Member Avatar for katsmiley

Because the different format specifiers tell `printf()` to interperet the value differently when displaying it. When you use `%c`, it tells the program to read `ch` as a single character, in this case printing out the character with the ASCII value of 23. When you use `%d`, it tells the …

Member Avatar for Tumlee
0
323
Member Avatar for kidpro

If you're wondering why nullptr made these suggestions, here's why. On line 14, you're calling `getch()` but you're not actually *storing* the value returned by it anywhere, so the program isn't doing anything with your input. Changing the line to `again = getch();` fixes this problem. The reason he's suggesting …

Member Avatar for Adak
0
130
Member Avatar for kayceedude

What code do you have so far? You're supposed to give us what you have so far, and we'll be happy to help but, but we're not allowed to be doing your homework for you.

Member Avatar for kayceedude
0
467
Member Avatar for nitin1

A segmentation fault indicates that you've accessed memory you shouldn't have. You should check variables that are being used as array indexes for these sorts of problems. This is one of those cases where you should debug with `printf()` to find out where your problem is. Track the value of …

Member Avatar for Tumlee
0
94
Member Avatar for SuburbanSamurai

Until we see what the `CALL_DATA` struct or class looks like, we can't really know for sure.

Member Avatar for Gonbe
0
223
Member Avatar for davecoventry

You're already halfway there when it comes to understanding this line, then. For this code to make sense, `src` has to be a pointer to a pointer type, such as `char**`, and `offset` has to be a pointer type, such as `char*`. What this particular line of code is doing …

Member Avatar for davecoventry
0
140
Member Avatar for ayushcr7

You're not accessing an array wrong, you're causing a stack overflow because `Solve()` keeps calling itself over and over again when the parameter is zero

Member Avatar for nitin1
0
105
Member Avatar for hello10

Assuming you're giving us all the information we need, there's a ton of ways to do this without using loops and `cout`. One could use standard C functions like `puts()` or `printf()`, for example. #include <cstdio> int main() { printf("**********"); return 0; }

Member Avatar for WaltP
0
163
Member Avatar for noblepants

Your equality comparisons makes so sense in `circleIntersections()`. On line 40, your condition is `else if(quadraticRoots(h,k,r,x1,x2)<0)`. Why are you checking to see if the number of roots is less than zero? Because `quadraticRoots()` only ever returns values of 0, 1, and 2, this `if` statement is never true. You probably …

Member Avatar for noblepants
0
418
Member Avatar for paul9519

When you push a `char*` into a vector, you're not adding the actual characters to the vector, but rather a memory address that points to the characters. What's probably happening in your case is that `file.cFileName` (a memory address) remains the same, so you keep pushing the same value over …

Member Avatar for Tumlee
0
215
Member Avatar for sharath_137

`malloc()` is C's equivalent of C++'s `new` operator. It is usually defined in `stdlib.h`. It allocates memory for your program to use. It takes a size argument, which must be manually scaled depending on the size of whatever type of data you're trying to allocate. For example, to allocate 6 …

Member Avatar for Banfa
0
594
Member Avatar for Lucaci Andrew

Your problem is in line 11. void insert(int i, string elem, vector<string> st) What you're doing here is a pass-by-value operation. This means that you're not actually passing your vector to the function, but rather just a *copy* of that vector. Your function modifies the copy, but the original vector …

Member Avatar for Lucaci Andrew
0
172
Member Avatar for caltech

Attempting a compile got me some errors. On line 138, you have `printPayroll( recordlist[] );`. There is no need for these empty brackets unless you're declaring an array. Remove them and that error should be solved. On line 164, I get the error that `r` has not been declared in …

Member Avatar for mike_2000_17
0
362
Member Avatar for mrmikemike

What are you trying to do with the variables `int u` and `int c`? It looks like you're trying to count the number of elements with both with `u`, but every time you increment it, you also make `c` the same value. In your `for` loop, you're setting `c` to …

Member Avatar for mrmikemike
0
165
Member Avatar for ashboi

Let's go through this problem by problem. **1)** You got completely confused while naming your member variables. As pyTony said above, in `student.h`: int newid; string newname; Should be changed to: int ID; string Name; To finish fixing these naming conflicts, change `Student::Student(int ID, string Name)` to `Student::Student(int newid, string …

Member Avatar for ashboi
0
162
Member Avatar for ObjectOriented

It's to make sure that the user of the class doesn't touch member data that he's not supposed to, or that when he does, it's in a fashion that is defined by the class (via a getter or setter function). In my opinion, a "read only" keyword would have been …

Member Avatar for Divyab
-1
309
Member Avatar for Hitman Mania

> and you can use void main() there is no need of making it int. Disregard this advice, Hitman. > then what is the problem??? This should explain why `void main()` is not only wrong, but it can also be dangerous: http://users.aber.ac.uk/auj/voidmain.cgi Otherwise, the above code is more or less …

Member Avatar for BobS0327
0
204

The End.