Hmm... Thanks for explaining that, it makes a bit easier to think about definitions and declarations.
:D
User Profile
Collapse
-
I've always been very week in my terminology. I apologize for that. I believe it's called "type definition". I'm referring to the chunk of code that is something along the lines of the following:
By "struct made global", I'm referring to the previous reply (by Ganon11) which suggested that the struct definition should be moved outside of the function....Code:struct a { int i; };Leave a comment:
-
It doesn't compile on g++ 4.2.4
Making the struct definition global produces a different kind of error. But, if the struct is made global and the line
vector <acct> accounts;
is replaced with
vector <struct acct> accounts;
it compiles and linksLeave a comment:
-
This is MS-ism. Apparently, ^ is to signify a handle, which acts basically like a pointer, but is garbage collected (hence gcnew instead of new: gc stands for garbage collected).
Given that it is garbage collected, it will be deleted for you once there are no more preferences to that address... hopefully.Leave a comment:
-
I see two (and a half) things that I would fix.
The half is that half of your malloc returns are cast and have are not. Pick one (not casting malloc is the correct thing to do in C).
Other than that,
1. You might want to check if letter is negative before you index into an array using it. I'm referring to character-65 calculation. There are plenty of characters that will cause that expression to be negative....Leave a comment:
-
Post your code please.
It seems that the problem you have is you just read what you need, and then write it back to the file (overwriting much of everything else).
What you need to have is to read all of the entries, modify the required ones, and write all entries backLeave a comment:
-
assuming that you allocate enough space to the char*, you can use sprintf in a loop
you want to initialize your str to an empty string, and then keep printing to the end of it. You know the end of the string with either strlen or some calculation using sprintf's return code.
In my opinion that would be as simple as any other approachLeave a comment:
-
Is there a way I can contact you with more direct and faster messaging, such as AIM or MSN. The jump we made in this programming level has pretty much screwed me over.
We went from basic enter a text to A.I and user real time input as well as moving object. I'm really baffled and could use some help, if you have time -
Googling long double gets me to this article:
Long double - Wikipedia, the free encyclopedia
Reading about it, and narrowing it down to 128 bit long double, makes me click a link in that article to the following article:
Quadruple precision - Wikipedia, the free encyclopedia
That one describes how it is stored, it's ranges, and some examples. Finishing with the first article, I get the impression that...Leave a comment:
-
You are missing a semicolon after return 0. Also, for the future: it would be extremely helpful if you, aside from posting your code, also post the error you get.
Typically, we are much better at understanding the error message than we are at just skimming the code and figuring out what's wrong.
good luck! :DLeave a comment:
-
As Studlyami said, your ONOrOFF function just checks array[row-1][column]. It has the correct row > 0 check, but you also need to check other array positions.
row < 9 && array[row+1][column]
column > 0 && array[row][column-1]
etcLeave a comment:
-
It looks pretty good so far, I mean... I think some variables are missing? Did you post the whole code? If so, does it compile?
One note in the OFFOrON function: make sure you don't go outside of the boundary of the array. For instance, if row is 0, then arrayCells[row-1][column] will result in a segmentation fault. You should do something like:
if ( (row > 0) && (arrayCells[row-1][column] == 1) )
...Leave a comment:
-
You have to add keyword typename before your definition of it.
i.e.
Why, you ask? I only vaguely understand that this helps the compiler understand that map<T, set<string> >::iterator is a type, not something else. Shouldn't it know it by itself? Well, no, because you put in a template parameter in there, which can be anything...Code:typename map<T, set<string> >::iterator it;
Leave a comment:
-
Post your changed code, please. (put [ CODE ] before it and [ /CODE ] after it (without spaces in between the brackets)Leave a comment:
-
If you are a beginner, use a character array (like char array[50] instead of char *array).Leave a comment:
-
I prefer looping over the number of bits and doing a check along the lines of
If that is true, then bit curbit is set (the least significant bit being bit 0). This is very similar to what weaknessforcats said, except that one isCode:if ( num & (1 << curbit) )
:DCode:if ( (num >> curbit) & 1 )
Leave a comment:
-
It would help if you post what messages you are getting...
Maybe you forgot to return 0 in main? Or maybe your version of strcmp return 1 when the strings are not equal, yet the if statement in your main implies that it returns 1 when they are equal?
(and, of course, you don't allocate any memory to your pointers, as mentioned above)...Leave a comment:
-
We're here to answer, so don't be sorry for asking.
Umm... Well, from the code you have, I don't see a simple way out...
you have function A and function B (A happens to be main)
in A, you move the bar and call B
in B, you move the thunder all the way down.
So you see, you can't move the bar while the thunder is moving down, because the control isn't going to return to A until the thunder...Leave a comment:
-
Suppose you only have one thunder at any point in time. Say you have thunderx and thundery for it's position and thunderexists as a flag meaning it exists (this should all be stored in a struct, if you have studied that)
Then you can have something along these lines (and forgive me if it doesn't compile, I'm just typing it in, not testing it)
...Code:// infinite loop for(;;) { if(thunderexists == 0)Leave a comment:
-
You don't understand the concept of reading strings from file? What piece of code from your C book do you not understand in particular?Leave a comment:
No activity results to display
Show More
Leave a comment: