202 Posted Topics
Re: Try [URL="http://www.paulhorst.com/c241/stacks.htm"]http://www.paulhorst.com/c241/stacks.htm[/URL]. Let me know if that works. | |
I am trying to use sprites, which I made in the form of bitmaps, in my program. Is there a library that will allow me to easily display them? I tried to use OpenGL but my computer will not allow it to initialize. I would simply like to display bitmaps … | |
Re: If you change the numbers[] array so the first element stored is the length of the array, then you can eliminate the second variable and simply keep passing the array to the function. | |
Re: strcmp compares the actual values of the character array (string) and the string literal you supply. So you are checking to see if argv has either the value [y][e][s][\n][] or [n][o][\n][][]. If the letters are capitalized, then the binary values for the letters are not the same, meaning that the … | |
Re: You can loop through a string and find the '/0' though, correct? | |
| |
Re: Global variables are variables that are declared outside a function, meaning that they can be accessed anywhere in the program by any function. Any variable declared outside of int main() is a global variable. Using global variables is not good programming technique, although it can be done. | |
Re: You will probably want to store the name as a string, the dates in one array, and the heights in another. Make sure the jump distance array is double or float. Then sort height list in ascending order, make sure that when you move a value in that array that … | |
Re: If you want to use modulo without floating points try (int)myFloat % (int)myOtherFloat | |
Re: Couldn't you just call the mirror function from within the inorder function? | |
I followed Ancient Dragon's advice and used vectors to store roughly 1000 objects in a program I have written. Unfortunately, the vector library is not one I am familiar with. I read through the information at [URL="http://www.cppreference.com/cppvector/index.html"]http://www.cppreference.com/cppvector/index.html[/URL]. It seems getting a reference to each element of the vector is the … | |
Can anyone spot the error in my code? The program will enter the last while loop but continue in an infinite loop... I figured fresh eyes may help spot the flaw! [CODE] int xlist[1500], ylist[1500], counter = 0, tempx, tempy, tempcounter; bool assign = false; while(counter < 1500) { xlist[counter] … | |
I have a program that has a custom class that I would like to create many of and access them like an array. Example: [CODE]#include <iostream> using namespace std; class Thing { public: Thing(int value) { a = value; } int doStuff(int diffValue) { a = diffValue + a; } … | |
Re: Couldn't an undefined symbol also refer to a package that wasn't imported? | |
Is there any way to clear the screen in a console app? I noticed that System does not even appear to have a system call similar to the system("COMMAND"); of C++. Any ideas? | |
Re: I think its because you never increase the step integer so karel never stops the karel.move(); and karel.putBeeper(); routine. If the move(); method doesnt increase the step counter, then karel will never exit. Put something like step = step + 1; in the while loop to see if that fixes … | |
Re: I think you mean this: [CODE]#include <iostream> #include <ctime> using namespace std; int main() { int array[100], counter = 0; srand((unsigned)time(0)); while(counter < 100) { array[counter] = rand(); counter++; } return 0; }[/CODE] That's a simple solution if I understand your problem... | |
Re: [CODE]#include <iostream> using namespace std; int main () { int age; cout <<"How old are you?:"; cin >> age; if(age > 12 && age < 19) { cout << " You're an teenager "; } else if(age > 18) { cout << " You're pretty old "; } else { … | |
Re: cls is Windows-specific so it won't work on all platforms | |
Re: [CODE]#include <fstream> #include <iostream> using namespace std; int main() { int a = 1; fstream yourFile; yourFile.open("log.txt"); yourFile >> a; yourFile.close(); return 0; }[/CODE] Something like that. Maybe the ">>" needs to be "<<". | |
Re: Two tips: first, you have commented that there is an end to a while loop where the three temps are entered, but there is no loop and I have had problems using fstream. You can declare it as "fstream myFileInput("input.txt"); without the ios::out. | |
Re: Perhaps opening and closing the string for the box causes a 'return' to be placed on it each time. Then, when you open the string again, the stream starts at the end of the string, which would cause it to be on the second line, then third, etc. Try accessing … | |
| |
Is there a reliable, cross-platform way to pause a program for a set amount of time? The getch() function will wait for user input, but I would like to be able to pause for say 3 seconds. If a for loop is used like so: [CODE]#include <iostream> using namespace std; … | |
Re: It wouldn't compile on Dev without using <iostream> instead of <iostream.h>... otherwise. The other problem is that you're declaring functions that you never call. When you declare double previous, current and unpaid in main(), you are creating variables with those names, not calling the functions. Try this: [CODE]#include <iostream> #include … | |
I was wondering if anyone was familiar with reading data from a file into your program. I tried using the file stream the same way cout is used but it doesnt seem to work properly. Would the getline(); function work? If so, how would that be implemented? [CODE]#include <iostream> #include … | |
Re: Try Data Structures and the Standard Template Library by Collins, C++ GUI Programming with QT 4, and perhaps C++ for Game Programmers. Those three books helped me a lot. | |
I'm having trouble getting fstream to function properly. I cannot open a text file while using any of the available parameters. My program calls mainprog() and functions correctly if I compile it as follows: [CODE]fstream openfile; openfile("my_file.txt"); if(openfile.fail()) { cout<<"Error opening file."; } else { mainprog(); }[/CODE] But if I … | |
Re: [QUOTE=ankit7;677042]hiii, thanks for the reply but i m getting some errors in the program after running the program ........the error are like.... 1. unable to open include file 'windows.h ' 2. undefined symbol 'HWND'. 3. statement missing ; 4. function 'ShowWindow' should have a proto type. 5. undefined symbol 'SW_SHOWMAXIMIZED'. … | |
Are there any standard C++ libraries that support multithreading other than windows.h? | |
Re: I'm just dabbling in the communications section but I wondered what you meant by framing the message with "\n" to reassemble it. Do you mean sending something like an array of characters with a "\n" placed in the last entry and then piecing all incoming data together until a "\n" … | |
I recently completed a small console app that accepts input from the user and places it in a floating point array, which was implemented through a for loop. I have not spent much time studying error handling and was wondering if anyone could refer me to a useful error-handling tutorial. … | |
Re: Start by accepting the weight in ounces and converting it to grams. Then divide the weight in grams by the number of grams/ton to get the weight in metric tons. Then divide a metric ton by your weight in grams and you have the number of boxes needed. | |
Re: I'm trying to convert from char* to int. Is there an easy way to do that? | |
Is there an easy way to convert from Char* to int? I have tried converting as such: [CODE]char* value_a; int* temp = value_a; int final = temp;[/CODE] The compiler is returning an error so I know something is wrong but why can't I convert this way? Any suggestions as to … | |
I have a problem that seems like it should be easy but so far has been fairly difficult to find documentation on... I want to be able to pass parameters to a program in the command line in the same manner as the built in functions (ex. the "/r" in … | |
Re: The easy fix is putting in your XP CD, going to the recovery console, and running FIXBOOT and FIXMBR. These should replace the NTLDR and get your machine to boot. | |
I am almost done with a project and now I would like to code an installer for it. I know there are many free solutions to make installer packages online, but I would enjoy learning how to make one from the ground up for the expirience if nothing else. What … | |
Re: Make two variables, one for min and one for max. Assign them to the first two numbers in your sequence. Compare each new element that you encounter with the min and the max. If it is larger than the max or smaller than the min, assign it. When you have … | |
I was wondering if anyone could recommend a powerful library for communicating with USB jump drives? My attempts to locate a solution on Google have not provided much in terms of usefulness. I would simply like to read and write to the drive, perhaps even find the size of the … | |
Re: Can't a literal constant also be defined as const float pi = 3.14159265358979323? | |
I was wondering if anyone could help me with what should be a simple PHP script. I want to write a text file, inputing different strings to different lines using some predefined lines and some input from a text box, then save it with another extension (such as .ini). Here's … | |
Re: You need to use fstream... here is a good reference [url]http://www.cplusplus.com/reference/iostream/fstream/[/url] | |
Re: You could also insert std::system("PAUSE"); between 18 and 19 | |
Re: Place your points in an array and use a loop based on the number of points to calculate the distances, checking each result with the last to see if it is less. If so, it should become the new "shortest distance" | |
Re: Maybe the best way to do this would be to error check after each input, then move on. while(input1==false) { cin>>input1 } while(input2==false) { ... | |
Re: The error makes it sound like you're trying to redefine the function in your main file. You need to declare an instance of a class to use the functions in it. | |
Re: Open the file with fstream, search for the line with the id you wish to edit, then write to that line. A nice reference can be found at [url]http://www.cplusplus.com/reference/iostream/fstream/[/url] | |
Re: Try using a .bin file (binary)... this will make it nearly impossible for the average user to access your password database. |
The End.