299 Posted Topics
Re: See this line? `class War: public Game` You're declaring War to be a derived class of Game. See this line? `class TicTacToe` You're declaring TicTacToe to be a class of its own with no base class. | |
Re: > if(arr1[j][0] == arr2[k][0]) This is not how to do string comparisons in C. http://www.cplusplus.com/reference/clibrary/cstring/strcmp/ When the two strings are the same, strcmp will return 0. There may be other bugs, but this is the one that stood out to me. | |
Re: OK, claywin, we really can't help you the way you want us to. Not with the information we have. So here's what we're going to do: SDL_Rect rcSrc, rcPlayer; std::cout<<"Player object created!\n"; SDL_Init(SDL_INIT_VIDEO); std::cout<<"Video initialized!\n"; SDL_WM_SetCaption("Untitled", "Untitled"); std::cout<<"Caption set!\n"; screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); std::cout<<"Video Mode set!\n"; temp = … | |
Re: In regards to your redundant **class X;**, remove them from the beginning of each header not counting **A.h**. You're including the header files so you don't need an additional **class** statement. In regards to the run-time error: yes, exactly. A pointer is not the object it points to. It's like … | |
Re: http://www.opengl.org/sdk/docs/man/xhtml/glGenTextures.xml >There is no guarantee that the names form a contiguous set of integers; however, it is guaranteed that none of the returned names was in use immediately before the call to glGenTextures. | |
Re: Learn to read data in from files: http://www.bgsu.edu/departments/compsci/docs/read.html [http://cpp-tutorial.cpp4u.com/STL_ifstream.html](http://cpp-tutorial.cpp4u.com/STL_ifstream.html) http://www.cplusplus.com/doc/tutorial/files/ Learn dynamic memory allocation: http://www.cplusplus.com/doc/tutorial/dynamic/ http://www.yolinux.com/TUTORIALS/Cpp-DynamicMemory.html Use a nested **for** loop. Vote for Pedro. | |
Re: Well, there are a couple of things you can do. You can poll the queue repeatedly, checking to see if it's not empty. void someFunction(){ while(1){//Loop forever. if(myQueue.Empty()==false){ doSomethingAmazing(myQueue.popFront()); } } } This is kind of wasteful. Or you can put in an observer-relationship. You create an observer object list … | |
Re: EDIT: Labdabeta beat me to it! I spent so much time on this one! Darn the luck! I'd suggest a recursive function with a backtracking mechanism like a stack or a double-ended queue. deque<yourClass> *myRecursiveFunction(vector< vector< yourClass > > *dataSet){ deque<yourClass> *dataSelected=new deque<yourClass>(); if(myRecursiveInnerFunction(currentDataSet, 0, dataSelected)) return dataSelected; else return … | |
I need GMPXX on MinGW. This is driving me nuts. EDIT: I should mention I've tried using the precompiled MinGW GMP and GMPXX libraries via the **mingw-get**. And they fail. I removed them. I compiled GMP in MSYS with the following line. ./configure --enable-cxx --prefix="/mingw" && make && make install … | |
Re: @Lerner: Actually, suhasgh's right. The **delete** kills the object instance, but the **erase** deletes the lingering pointer kept in memory. However, I'm curious about the erase statement and if it's killing the right entry each time. As far as the **for** loop that cleans up, I'd yank the erase. Then … | |
Re: Props to nezachem. I was going to suggest the same thing. Did a little research on some broadcast tuts and learned that APPARENTLY broadcast is dead, long live multicast. Huh. http://lmgtfy.com/?q=winsock+multicast+example Also, don't forget that with any WinSock program you write, you'll need to link in the appropriate library for … | |
Re: OK, explain this bit. slen = (unsigned) strlen(keyPtr); slen2 =(unsigned) strlen(keyPtr2); if( strlen(slen) == NULL && strlen(slen2) == NULL) { fprintf(stderr, "\n\tNo keys entered. You must enter 2 keys.\n"); error = 1; } if(strlen(slen2) == NULL) { fprintf(stderr, "\n\tOnly 1 key entered. You must enter 2 keys.\n"); error = 1; … | |
![]() | Re: Two thoughts on this one. A. Use [memmove](http://www.cplusplus.com/reference/clibrary/cstring/memmove/) (which allows source/destination overlap) to relocate the values like so: memmove(&data[51],&data[50],49*sizeof(int); data[50]=42; B. Use a for loop that works backwards. for(int i=99;i>50;i--){data[i]=data[i-1];} data[50]=42; Frankly, the second should have been a little obvious. |
Re: First, here's a tutorial on pointers: /* ============================================================================ Name : PointersExplained1.c Author : Dean M. Sands, III Version : 0.1a Copyright : I will set fire to the flamingos in your front yard. Description : A code explanation of pointers ============================================================================ */ #include <malloc.h> #include <stdio.h> #include <conio.h> int *i; … | |
I'm using the 620 WinLoader software that ties to an ancient Honeywell LM 620-25/35. And I've gotten it to work in a one-to-one connection with an RS422 USB adapter. (After lots of rewiring cables.) Now the tricky part. I've got a coworker who wants to remote into a single box … | |
Re: Your code is already to go really. Just make these changes: /* Read lines from input file */ while(fscanf(finp, "%s", line) != EOF) { insert(head, line); } void insert(struct tree_node *head, char *li) { if(head == NULL) { head = (struct tree *)malloc(sizeof(struct tree_node)); if(head == NULL) { printf("Node allocation … | |
![]() | Re: The Compiler is expecting you to use a Class object with those functions unless you declare them as static. In your header, put [B]static[/B] in front of the declarations (i.e. right before the word [B]void[/B]), but not in the implementation. |
Re: I'm not entirely sure what you're trying to accomplish with the squeeze function. I will tell you this: Instead of [CODE]for(i=0; i<s1; i++) {[/CODE] you probably want [CODE]for(i=0; i<strlen(s1); i++) {[/CODE] strlen requires [B]string.h[/B], not to be confused by the C++ [B]string[/B] header. | |
Re: Any modern compiler will work for you. That said, I recommend starting out with Code::Blocks. [url]www.codeblocks.org/[/url] While this isn't the biggest and the best, it's one of the easier methods. For Graphics, you will want to use DirectX, OpenGL, Allegro, SDL or SFML. The easiest is SDL. [url]http://wiki.codeblocks.org/index.php?title=Using_SDL_with_Code::Blocks[/url] When you've … | |
Re: [CODE]If the input for the gender doesn't match 'F' and doesn't match 'M' complain and exit. if(gender!='F'&&gender!='M'){ cout<<"Invalid Gender."<<endl; return 0; } If the input for the activity doesn't match 'I' and doesn't match 'A' complain and exit. if(level!='I'&&gender!='A'){ cout<<"Invalid Activity Level."<<endl; return 0; }[/CODE] | |
Re: [LIST] [*]Use "Product Activation" [*]Use a web-installer with a server that generates content encrypted for that machine only. [*]You don't. [/LIST] Happy coding. | |
Re: This will get you started. [CODE] #include <iostream> using namespace std; string studentName[10]; float studentMark[10]; char studentGrade[10]; char getGradeByMark(float mark){ int iMark=(int)(mark/10); switch(iMark){ case 10: case 9: return 'A'; case 8: return 'B'; case 7: return 'C'; case 6: return 'D'; default: return 'F'; } } void getStudentData(int student){ cout<<"Input … | |
Re: [url]http://www.daniweb.com/software-development/cpp/threads/341509[/url] Props to AD for this one. I upvoted his post. You should do the same. | |
Re: Are you running Windows, Mac, or Linux? If Windows, are you using Visual Studio, NetBeans, Eclipse, Dev-C++ or Turbo C++? | |
Re: Maybe you mean ellipse? [url]http://msdn.microsoft.com/en-us/library/6hkxb3kd(v=vs.80).aspx[/url] | |
Re: To what platform or format? If you're talking about to the console, eh, you're going to have to write a function that generates an array of multiple lines and offsets the sub and super script text to their corresponding position in the main line of text. For example: [CODE] n … | |
Re: You only have pointers. The memory space isn't allocated yet. If you were using arrays, that'd be different. [CODE] struct Adress{ char street[32]; char postal[32]; int zip; }; struct Person{ char firstName[32]; char lastName[32]; struct Adress home; }; [/CODE] EDIT: This might be helpful. [URL="http://www.cs.stanford.edu/cslibrary/PointerFunCBig.avi"]Stanford Explains Pointers.[/URL] | |
Re: ADHD in IT? No, but definitely ADD. What do I avoid? Anything involving backing up and making system-generic images for. Not that I get out of it, mind you. | |
Re: You can't use arrays? Can you use linked lists or trees? EDIT: How did we all reply at the same time? | |
Re: What version of Allegro are you using? That looks like older Allegro code. Allegro 5 uses a whole new API. I compiled Allegro 5 on my system using MSYS, MinGW and CMake. Then I tried compiling that code. Didn't take. Tried code from the Wiki. Worked without any problem. | |
Re: Look into cross-platform libraries. I like SFML. Unfortunately version 2 isn't finished yet. SDL has been around forever and a day. It has a nice community following. There are others. Google is your friend. Happy coding. | |
Re: Scripting engines and graphics loading, saving & manipulations. See if you can take a script, some single frame sprites, background tiles, and generate a single scene. Export it to JPEG or PNG. Heh, I need to try that. | |
Re: [CODE]long fileSize; fseek(input, 0L, SEEK_END); //Go to end of file fileSize = ftell(input); //Current position is the file length rewind(input); //Rewind to beginning[/CODE] Then just do a [B]for[/B] loop. As for speed, your fgetc is killing you. Single character reads is too slow. Once you know your file size, [B]malloc[/B] … | |
Re: No. But I will give you this. [CODE] #include <stdio.h> int main() { int i; char oneDimensional[]="I am one-dimensional!\n"; char twoDimensional[5][5]={ "I am", {'t','w','o','-',0}, "dime", "nsio", "nal!" }; printf("%s",oneDimensional); for(i=0;i<5;i++){ printf("%s",twoDimensional[i]); } return 0; } [/CODE] Which outputs this: [CODE]I am one-dimensional! I amtwo dimensional![/CODE] Yes, I know it's missing … | |
Re: Allow me to make some adjustments. [CODE]#include <iostream> #include <string> #include <vector> #include <cstring> #include <cstdlib> using namespace std; class ship { char Name[256]; vector<string> inventory; public: void setName(char *nam) { strcpy(Name, nam); cout << Name; } void addToInventory(string frt, string sec, string thir) { inventory.push_back (frt); inventory.push_back (sec); inventory.push_back … | |
Re: Are you giving QUWI enough time to finish? It looks like you're queuing the thread, then exiting. Have a look at this: [url]http://developer.amd.com/documentation/articles/pages/125200687.aspx[/url] In this code, when the last thread finishes, it signals an event, which the main function waits for before exiting. | |
Re: A char tends to be 8 bits. An int on a 32-bit machine is 32-bits. If an int contains a 2, it actually contains {2,0,0,0} (in a 32-bit system) Try this code: [CODE]#include<stdio.h> int main() { unsigned int i, j; int arr[3]={2,3,4}; char *p; // p = (char*)arr; // line … | |
We have 32 data gathering sources all operating at 100Mb. They tie to a single server. Currently, we're using a 100 Mb network. We've have 2 Trendnet TEG-424WS units we can put in. They come with 24x100Mb ports and 4x1Gb uplinks. Can we tie the server to one of the … | |
Re: Floats and Doubles see the world much differently than integers do. Do an is it equal to...? will probably have some weird results. My advice, change it to [B]while(!(hoursWorked<0))[/B] Reference: [url]http://en.wikipedia.org/wiki/IEEE_754-2008[/url] | |
Re: Have you set up port forwarding on your router? Secondly, have you tried accessing your server from a computer outside your local network - like a laptop at an internet cafe. Reference: [url]http://en.wikipedia.org/wiki/Port_forwarding[/url] [url]http://portforward.com[/url] | |
Re: Compiled in MinGW under Eclipse without changing any linker settings. Ran fine for me. What compiler are you using? (And where did you get it?) | |
Re: Read this code, then fix it. [CODE] #include <string> #include <iostream> using namespace std; int main(){ string s1="123"; //Set up string 1 string s2="456"; //Set up string 2 string s3; //Setup string 3 cout<<"First string: "<<s1<<endl; cout<<"Second string: "<<s2<<endl; s3=s1; //Copy string 1 into string 3 for(int i=0;i<s2.size();i++){ //Loop through … | |
Re: Absolutely. Write a socket server. Then write a chat server and client. When you get finished with that you will wonder why I told you to. Then it will suddenly become obvious. [url]http://www.codeproject.com/Articles/13071/Programming-Windows-TCP-Sockets-in-C-for-the-Begin[/url] [url]http://www.codeproject.com/Articles/14032/Chat-Client-Server[/url] | |
Re: [QUOTE]...at what point do you start to learn the more advanced stuff?[/QUOTE] When your professor's first spoken language is not the same as your own. That's when you get into the crazy stuff. | |
Re: Something's wrong somewhere and I'm not entirely sure where. It seems like it SHOULD WORK, but SHOULD WORK rarely works the way it should. Have a look at this: [url]http://en.wikipedia.org/wiki/Equations_of_motion#Applications[/url] (I don't know why they picked the variables they did, but they did.) A free fall object at point [B]s[/B] … | |
Re: A moving average would look like this: Average = 0.0 (Use doubles) Number of elements = 0.0 Total = 0.0 While there are more numbers: Ask for a new number. Add new number to total. Add 1 to number of elements. Divide total by number of elements. Store in average. … | |
Re: This is a poorly made list, but I was (am) in a hurry. 0.a. Arrays 0.b. Pointers as arrays 0.c. Pointers to Pointers 0.d. Pointers to Pointers as Arrays of Arrays (I learned Pointers by using Iceman's C rewrites of Denthor's VGA trainers.) 1. Stacks as arrays 2. Double-Ended Queues … | |
Re: Here, let me google that for you: [url]http://www.codeproject.com/Articles/24684/How-to-create-Linked-list-using-C-C[/url] | |
[url]http://www.cs.stanford.edu/cslibrary/PointerFunCppBig.avi[/url] Main Page Link: [url]http://cslibrary.stanford.edu/104/[/url] (If this helpful to anyone, it is technically not trolling.) |
The End.