166 Posted Topics
Re: Furthermore, it should be `int main()` not, `void main()`, and you should have `return 0;` at the end of your program. | |
Re: One issue is here: `&(*mPntr)` The other is here: `&PntrFunc(&(*mPntr))` You can't get the location of `*mPntr`, because that's an expression, so your code doesn't make any sense. It would be like if you were to try to do this: `int* ptr = &(a + b);` It's obvious to see … | |
Re: > Use a new version of the compiler with the bug fixed I suggest this one, because ideally a compiler shouldn't crash no matter what you feed it. | |
Re: Java has the advantage that is has a virtual machine that runs under many Operating Systems. Like so, you can expect many things to work on as well on under OSx as you are under Linux and Windows (more or less). I don't really understand the point of C# though. … | |
Re: > You can use Adobe Flash to make an app. How can he use Adobe Flash to make an iOS app, when iOS doesn't support Flash? Apple pretty much has the whole App-making thing locked down to where you can't produce any iOS app without owning an Apple computer. From … | |
Re: You're probably creating a text file, but then you're just *naming* it like a PDF. Just changing the file extension doesn't change the data inside the file, it's still just text. That would be like calling your chicken a pig, slaughtering it, and expecting it to taste like pork. > … | |
Re: You first issue is on the lines that say `cin >> people.fname >> people.lname;` and `cout << people.fname << people.lname;`. The token `people` refers to the type of the structure, not its name, so this results in a syntax error. Since it's a member function, change these lines to `cin … | |
Re: GBA programming seems like a hassle because you would have flash it to a cartradge, and deal with the GBA's various limitations. I'll throw SDL's hat in the ring, as always: http://www.daniweb.com/software-development/cpp/threads/418882/game-design-classes-and-inheritance/1#post1786924 | |
Re: > So would this be correct then? Close, but remember that `return` statements immediately exit your funciton, so the way you wrote your code, `tf` would never be set unless `value1` and `value2` are equal. You want to swap the `return`s and the setting of `tf`. | |
Re: SFML still has some maturing to do. The last time me and my friend tried to make something with it, it turned out it didn't even support certain computer architectures. In the meantime, I suggest using SDL, and it's extensions, SDL_mixer and SDL_image, to make a game. With the proper … | |
Re: As said above, you need to call `fclose(ftdata);`. To prevent future headaches, your third argument (count) should be set to 4 instead of 2 if you want to fully print `"TEST"`. | |
Re: The best thing to do is to show us the class or struct you're using as a box. | |
Re: You are calculating the maximum value correctly, but you are forgetting to actually print it to the screen. The following should print your value. [code=C++]cout << "The maximum value is" << Max(s,n) << endl;[/code] | |
Re: In your declaration of [icode]mergesort()[/icode], you are giving it two arguments. [code=C++]int mergesort(int,int);[/code] But when you actually define the function, you gave it three. [code=C++]int mergesort(int first,int last,int mid)[/code] That is a mismatch, and it results in the linker error you ended up with. You fix this by changing either … | |
Re: This is definitely one issue: [code=C++]printf("max = %d\n", max); printf("min = %d\n", min);[/code] [icode]max[/icode] and [icode]min[/icode] are not integers, they are functions that return integers, so these lines of code don't make any sense. I'm not even sure how you got this to compile, but your program is probably printing … | |
Re: I actually found it Visual Sudio's "Intellisense" irritating when it was pestering me, putting red underlines on all my code and giving me suggestions when I wasn't done writing my program yet. I prefer CodeBlocks because it's still an IDE that allows you to easily manage a large project, but … | |
Re: Are you trying to just turn the vowels into spaces? If so, your code works perfectly on my end. | |
Re: The header you're looking for is [icode]<dirent.h>[/icode], which allows you to use the [icode]opendir()[/icode] function. That function opens a specific folder and allows you to iterate through all the files in that folder and view their names and sizes. If you look up tutorials on using that library, you'll find … | |
Re: If the algorithm was "simple" it probably wouldn't compress very well. If it helps you understand better, many compression algorithms actually [i]can[/i] end up making a chunk of data larger if it's not suited for the task (notice how sound files don't compress very well at all with ZIP compression). | |
Re: No, the code is not correct at all. It's not supposed to be [icode]<iostream.h>[/icode], it's just supposed to be [icode]<iostream>[/icode]. You shouldn't be using <conio.h> at all, because that just allows you to use old DOS-isms that can be done in a more portable way. You're not supposed to use … | |
Re: There is no such thing as an EXE that will run under all machines. Turbo C makes DOS programs. DOS compatibility has been whittling away on Windows (and for good reason). There is no guarantee that your program will work perfectly under any operating system newer than Windows 98, unless … | |
Re: There is no difference unless you're using a class that detects the type of the data and does something different with it depending on that type. For code clarity, you should use 0 when talking about a number, '\0' when talking about a string-terminator, and NULL when talking about a … | |
Re: He's expecting the compiler it to align all instances of this structure to 4-byte boundaries via padding. I'm not entirely sure if this should actually change the value returned by sizeof(). | |
Re: [QUOTE=Peter4n31;1746735]"Just make an empty method" I would need a little help. How to do it ? (I know it sounds stupid but I haven't touched c++ in 10 years...)[/QUOTE]You would just make a function put nothing in the brackets except for a [icode]return;[/icode] statement in this case. If the function … | |
Re: When I make an SDL program (compiled under Windows 7), it doesn't require any such DLL even under Windows XP. Ichigo, would you happen to be building your game under Microsoft Visual C++? I know that even terminal programs made with that compiler require that DLL for some reason --- … | |
Re: If you want to create a program in C or C++ with graphics, you should first switch to a modern IDE (like Code::Blocks or Visual C++). From there, you should learn how to a library like OpenGL, SDL, DirectX, or something similar. | |
Re: Why use [ICODE]while(0==0)[/ICODE] when you could just use [ICODE]while(true)[/ICODE]? Furthermore, why would you use a do-while loop when your condition is infinite? | |
Re: Most environment/compilers require a newline at the end of your file, otherwise it won't compile. Some will even go as far as to add them in [i]for[/i] you. Try adding it in and see if that resolves the problem. | |
Re: C++ and C are just as capable as any other language when it comes to using the internet, networking, etc. There are all sorts of libraries out there to do that sort of thing. Even C can have, for example, a game that uses UDP that can be used for … | |
Re: [quote=firstPerson][code=C++]struct{ const int EAST = 0; const int SOUTH = 1; const int WEST = 2; const int NORTH = 3; };[/code][/quote]Who in God's name would use a struct like [i]that[/i]? That is [i]not[/i] what structs are there for. The [ICODE]enum[/ICODE] keyword is for where you want to have different, … | |
Re: What happens if you hold the up button? It looks to me like Lazyfoo forgot to add a check to make sure the dot wasn't on the ground. It will therefore occur that when you press the up button in a higher framerate, it will be down for more "ticks" … | |
Re: Are you talking about before your class is finished, or in the long term? If it's the latter, I recommend starting simple, like with a 2D game with simple sound effects. I highly recommend learning how to use the SDL library for this, as it has some pretty simple methods … | |
Re: Seems more like a user issue. I've had Vista for three straight years and the boot time has stayed a static 15 seconds for me. The Allow & Deny thing only happens the very first time you run a program, so that's not an issue. Windows 7 is officially more … | |
Re: (Good God, why does everybody here beat around the bush when somebody has a problem, just help the guy!) What I would do in your situation is to monitor all the variables involved (you don't even need a debugger for this, just make it print your variables in a loop). … | |
Re: [ICODE]new[/ICODE] uses brackets, not parenthesis. Furthermore, it's called [I]allocating[/I] memory, not [I]occupying[/I] it. [code=C++]char* temp = new char[255]; temp = "poiuytrewq";[/code] | |
Re: [ICODE]string compliments[4] = {"String 1", "String 2", "String 3", "String 4"};[/ICODE]This will create an array of strings that you can output. If you're going to use the [ICODE]string[/ICODE] class, you're going to need to include the proper header, which I believe is either called [ICODE]<string>[/ICODE] or [ICODE]<strings>[/ICODE] | |
Re: In the comments you'll see some potential problems with this code. [code=C]#include<stdio.h> #include<string.h> int main() { //You're intializing a two dimensional array with a one-dimensional initializer. //This may cause problems. char a[4][4]={'j','u','s','t'}; int i,l,j,k,b=4,n; //If b is the number of characters, why not name it numchars or something like that? … | |
Re: Exactly who keeps telling people to keep using Turbo C? Is there some antiquated book from the 1980's floating around and encouraging this? I'm assuming it's the same people telling everybody to use [ICODE]void main()[/ICODE]. | |
Re: There's a semicolon after your while statement on line 43. You need to get rid of that thing or your program will never work correctly. When you have a while loop with a semicolon after it your loop will do nothing except increment counters. At line 59, the statement [ICODE]else … | |
Re: [QUOTE=;][/QUOTE] First of all, you're not using your characters and integers consistently at all. It's going to cause you a lot of confusion in the future. The character [ICODE]'1'[/ICODE] is not equal to the number [ICODE]1[/ICODE] In [ICODE]readAndValidateUserMove()[/ICODE], there is really no need to use [ICODE]tolower()[/ICODE] on the input because … | |
Re: [QUOTE=;][/QUOTE] [code=C]Scanf("((%d/%d)*%d)", &Mark1, 40, 100;[/code] You're also missing a parenthesis at the end here. It should be: [code=C]scanf("((%d/%d)*%d)", &Mark1, 40, 100);[/code] | |
Re: [QUOTE=;][/QUOTE] [ICODE]result = SaveAudioFile(pFileName);[/ICODE] Are you sure a JPEG is supposed to be an Audio file? Furthermore, what libraries are you getting all of these functions from? | |
Re: That raises an interesting question: Once (if?) tablets become more popular for Windows users, how will that affect already existing software? Can we expect to see popular software redesigned with bigger buttons, or retooled to take advantage of multi-touch touchscreens? What about free libraries, like SDL (which has been in … | |
Re: Yeah, main() should never be called. I'm actually surprised that the compiler didn't yell at you for something like that, in many environments it's not even legal C. You should also not have to prototype main(). Once that code gets fixed, however, you might have problems because I'm not entirely … | |
Re: An array is just a pointer. The only difference is that arrays always point to the same memory and will have a static number of elements. [code=C]int main(int argc, char** argv) { int* ptr; //A pointer to an int. int array[4] = {2, 4, 6, 8}; //A static array. int … | |
Re: When you use #include <blah.h>, that doesn't mean you're actually using the libraries, those are just guides so the compiler knows what functions and variables exist outside of your own program. You need to actually [I]link[/I] them, or you're going to get all kinds of errors like the ones you … | |
Re: [I]i[/I] is used probably because it stands for [I]iteration[/I]. People choose to use it because [I]i[/I] is short and it looks clean when you use it as an array index (compare array[i] to array[numloops]). | |
Re: This is precisely why many C++ guides advise against using the equality operator with floating point values, because it can give you headaches like this. firstPerson's solution is okay for most applications. float == 0.0 is one of the few values for which it will work 100% of the time. | |
Re: [quote]...by this I mean you should never use a break statement in anything other than a switch[/quote]I agree with most of the stuff you said, but certainly not this. You should [I]avoid[/I] using a break statement in for loops when you can, but there are an awful lot of cases … | |
Re: Impressive, but: 1) Bases zero and one cannot possibly exist, nor could it produce any sort of sensical output nor input. 2) Using "int" will more than likely limit you. That's only four bytes in most environments, or eight hex characters. You should probably use the int64_t type. |
The End.