49,761 Topics
| |
Ok, I'm trying to write a little game in c++ using very simple graphics. not opengl or anything like that. Everything compiles fine (There are some warnings, i know how to fix them im just lazy, ill do it later) all of my code worked perfectly until i added the … | |
Hello- I need to do a selection sort on two different 2d arrays, sorting by the last column of one of them (thirdarray). The first column of thirdarray is the effective column size for the first (morearray) array. I am so confused. I cant find any examples to help me. … | |
This is the current assignment: Write a program that determines which of 5 geographic regions within a major city (north, south, east, west, and central) had the fewest reported automobile accidents last year. It should have the following two functions, which are called by [I]main[/I] [I]int getNumAccidents()[/I] is passed the … | |
Hello, I am trying to call two functions: one that pulls data from a file and stores into a linked list, and one that displays this data to the screen. I pulled my code out of the functions and created a new file and included everything in the main function, … | |
I have written a CString Object into Text file by using : f.Write (&FileName,FileName.GetLength());//FileName is CString Object Now I want to Read CString object back How this could be done?I am using code : LPTSTR p = CurrentLanguageName.GetBuffer(11); void *g=(void *)p; f.Read (g,CurrentLanguageFileLen); CurrentLanguageName.ReleaseBuffer( ); //But this method don't work. … | |
I am trying to read matrix data from file into a float vector the file has data like X = {1.0, 2.0, 3.0...........} Y = {3.4, 3.1, 3.4...........} I can read into vector strings. But I want to store the matrix names in a string vector and the matrix in … | |
I made this Data Table. The problem is when the outputs are different it will change the shape of the Table. I need some tips on how can i fix this problem. [code=cpp] [INDENT]double sum = 0; for ( int j = 0 ; j < 5 ; j++ ) … | |
why does this file outputs 516?? The value of numbers is being read from random.txt that has 200 random numbers in it. I was expecting this to output 200 and NOT 516.. whats up with this? [CODE] while (inputFile >> number) { //number of numbers on the file for (totalNumber … | |
Am a new c++ programmer. I refer to the code " Bouncing Ball" which is a GUI, now there is a rectangle created, i managed to change the color the rectangle in the main window and what my may problem is how to make the rectangle fixed and not only … | |
Does anyone have a solution/c++ code to make bmp images transparent on the fly without having to carry out 2 bitblt operations with the image and it's mask ? We want to develop a game in which there are many moving objects which have to be rendered transparent at new … | |
I am drawing a screen which requires refrehing,so Invalidate() function is called continously.Now I want to start a timer when screen is drawn first time.In the timer i want to call another function which draws another screen after some time.How this could be done? I have tried to start timer … | |
/cry i am having troubles with my c++ program i was asked to [quote] You will modify your program to allow the user to enter their move as strings of “paper”, “rock”, and “scissors”. Modify how the computer’s move is stored such that it is also a string of either … | |
I am having issues getting this function to work. This is a currency conversion program that gives the user choices of input of three other currencies other than USD and converts it. It is supposed to be a value returning function, not a void function. The program compiles, runs fine, … | |
this is my current code: [code] #include <iostream> using namespace std; void celsius(double); //Main int main() { cout << "Now displaying the first 20 fahrenheit temperatures and\n" << "showing the Celsius equivalent.\n"; //Loop for displaying the table for (int couter = 0; couter <= 20; couter++) celsius(couter); return 0; } … | |
This is what I've got so far: [CODE] #include <iomanip> #include <cmath> #include <fstream> #include<string> #include<iostream> using namespace std; int main() { double numA=0; double numB=0; double productB; double accumulator = 0; cout<<"Your two numbers to multiply are?"<<endl; cin>>numA>>numB; double productA = (numA * numB); if (numA>numB||numA%2==1)//check if larger and … | |
hey guys im tryin to do a conversion program im trying to convert pounds to kilograms i input 10 pounds and 4 ounces and it gives me a total of 4.65 kilograms but i want to split that up so it says kilograms and grams so it would be like … | |
hello .. after i write this program there's error i don't know why ? what's the wrong thing? [CODE]#include<iostream> using namespace std; class Account { private: int Acc_no ; double balance; public: void SetAccInfo() { cout<< " please enter your account number\n"; cin>> Acc_no ; cout<< " please enter your … | |
I have to make a program that enters either a 1, 2, 3, or 4 for 50 people attending a function. Then I have to be able to count how many of each 1's, 2's ,3's, and 4's there were. My 2 questions are: 1.) Would this program be better … | |
please give the c++ coding of how to do the following on a binary tree(BST) using recursion: (1) insert a new node (2) delete a node (3) search a tree | |
Hi, if we define a vector class, class vector { private: int size; int* array; ........... public: vector (int n=10); ......... } then we use it in main like this: int main() { const vector v(5); cout <<v(1) <<endl; return 0; } there's a problem with compiling this code, i … | |
I am creating a c++ class which randomly puts a number of particles on a lattice and then lets those particles jump on the lattice in a random fashion. I have managed to implement this, but using the random number generators rand(), which I understand is not a very good … | |
Hello - I am working on one of my labs, but I am having difficulty with the results being inconsistent. The passing by reference is working. I tested random data and I don't understand why some works and others produces incorrect results. Data tested: 5, 9, 7 = perimeter of … | |
Hello there, I met a problem which is to update inputs in a text file, but every time I update is only insert the data, not update. May anyone give me some advises? Thanks~ [code] string input; ifstream fin; ofstream fout; string title,author,category; float price; fin.open("library.txt"); cout << "******Update Book******"<<endl; … | |
>>i have defined a stack class using single linked list and a template. as follow: template <class T> class genStack{ public: void push(T a){.....} T pop(){........} .... .... private: SLList<T>: lst; } i know when i want the stack to store int, i should declare a stack like this: genStack<int> … | |
Okay, I got abotu 5 problems solved today and I am on the hardest part! Basically my code ask the user to enter series of random numbers and then use sentinel to mark the end of numbers needed to be entered. Now I want to be able to tell my … | |
[code] #include <iostream.h> int main(void){ int base; char num; cout<< "Enter a base: "; cin >> base; while((base>=2)&&(base<=10)){ } cin>>num; while((num-'0') < (base)) && (c>='0'){ base>=base*2+(num-'0') cin.get>>num; } cout<<base; cin.putback>>num; return 0; } [/code] Clearly, this program doesn't work very well. I am in need of help. The teacher really … | |
Dear all gurus, Given 30 files, with same format (2 columns, column1 is string and column2 is int. contains thousands of lines) and uniform file name, eg: file1.txt, file2.txt,...,file30.txt, How can i read it in a loop, and then load them into my 2D array (eg: string words [filesize][maxline], and … | |
Hi all. I'm a newbie to this forum so please forgive the odd question as first post... :-) I'm writing myself a [B]property[/B] class (just because I want to play with them). My property header looks something like this (all the usual clutter is removed): [code]#define property_readwrite( c, v, r, … | |
I am having trouble figuring out how to get my non recursive quicksort program to finish sorting. Here is my code [code] #include<iostream> using namespace std; /** * Swaps two items * * @pre x and y are the items being swapped * @post Contents of actual locations that x … | |
This is my first time working with outputting data to a file, so I've got some rough code that I need some pointers on. [code=cpp] else if (decision == "S" || decision == "s"){ cout << "File name? " <<"("<<filename<<")"<< endl; cin >> newfile; if (newfile == '/0'){ outdata.open("filename"); for … |
The End.