51,593 Topics

Member Avatar for
Member Avatar for allialli

hi. i have a program that i am having some troubles with. if anyone could give me any suggestions, it would be greatly appreciated! : ) i have to edit the main some more to get this to actually work. and i also have to add info into the function. …

Member Avatar for Ancient Dragon
0
128
Member Avatar for henpecked1

In my cdrom class I have a member function called returncost, and a private data member cost. [code] float cdrom::returncost() { return(cost) } [/code] Later, in a free function I call that member function to calculate a total cost and average cost. [code] void showcosts (cdrom &cd1, cdrom &cd2, cdrom …

Member Avatar for henpecked1
0
500
Member Avatar for infernojmd

Im trying to put a while loop in here and when i do i get tons of errors. but when i run it with out the while loop it works. this program inputs the first and last name and puts it as last, first. and uses strings for that and …

Member Avatar for Ancient Dragon
0
108
Member Avatar for blcase

[code=cplusplus] bool fun1() {if (root) return doFun1(root); else return false;} bool doFun1(Node *ptr){ if(ptr->left) doFun1(ptr->left); if(ptr->right) doFun1(ptr->right); if(ptr->left) doFun1(ptr->left); ptr->data=ptr->data*7; if (ptr->data>500) cout<<.5*ptr->data<<endl; else if (ptr->data<50) cout<<5*ptr->data<<endl; return true;} int main( ) { Tree t; t.insert(14);t.insert(13);t.insert(31);t.insert(27);t.insert(12); t.fun1(); return 0;} [/code] I am trying to trace through this and the output …

Member Avatar for hacker9801
0
120
Member Avatar for henpecked1

If I have a class called cdrom, and one of the member functions is loadinfo, what is the difference in these calls? cd1.loadinfo cd1->loadinfo I ask because my compiler is choking on the first and actually asking me if I meant to do the second.

Member Avatar for mitrmkar
0
96
Member Avatar for BabyEyes

Hi , this is the first time i ask for help here i have been searching for a good place to ask and i found daniweb i hope i be right of what i am thinking . and to get help from you guys. thank you here is the question …

Member Avatar for BabyEyes
0
130
Member Avatar for dacoon

Hi all, I have two asp.net dropdown lists, one for State selection and the other for County. Both have the autopostback set to true. When I try to navigate through the states using the keyboard (arrow keys) it selects the first state and I can't navigate through the rest of …

Member Avatar for ericstenson
0
98
Member Avatar for hezfast2

I'm working on a program that reads a file of scores and then outputs the number of scores in certain ranges. I've got it to read the input file (scores.txt) which is set up as follows; 76 89 150 135 200 76 12 100 150 28 178 189 167 200 …

Member Avatar for hezfast2
0
154
Member Avatar for bvrclvr1

Hi All, I am a student and this is a project I am working on. The main idea is that this program will calculate the number of months it will take to pay off a loan. There are catches in place to only allow positive entries and to check to …

Member Avatar for bvrclvr1
0
111
Member Avatar for Project_Panda

I'm using the directive pragma once in two header files. Both headers use vector, iterator, iostream, and string (and using namespace std). Some things may seem redundant and inefficient but it's the way our instructor wants us to write it. Anyways, in my file register.cpp, I want to include both …

Member Avatar for Narue
0
177
Member Avatar for Project_Panda

Specifically, specific elements. A project requires us to delete elements in a vector via course number. I assumed one would use an iterator, so that being said, would this work? [CODE]void student::drop_course(int d) { vector<int>::iterator f = find(c_id.begin(), c_id.end(), d); vector.erase(f); cout << "You have deleted course number " << …

Member Avatar for Project_Panda
0
147
Member Avatar for flower77

I am working on one-dimensional arrays for class assignment. I don't think I have this right. Can someone check this: The question is: Write the c++ code that will count the number of elements in an array (named number) of base type int. that are equal to a key value …

Member Avatar for Ancient Dragon
0
123
Member Avatar for anifreak

hello there! i'm new n i need real help! i got this homework and i have to have it done before tomorrow! i tried so hard n i cried all the last night *cries again* i hate queues!!!!! anyway plz help me if u can. i have to write 3 …

Member Avatar for William Hemsworth
0
132
Member Avatar for littlestone

What will happen if caught exception when new a object? For example: [code=c++] ClassTest* ptr = 0; try { ptr = new ClassTest; } catch(...) { } [/code] if the constructor of ClassTest throw exception, what will happen? will ptr == 0 ? some memory leak?

Member Avatar for Narue
0
168
Member Avatar for DigitalPackrat

I am creating a game, without using any game related libraries, only the "standard" (read aside) ones and an [URL="http://www14.brinkster.com/aditsu/dev-cpp-faq.html#conio"]edited conio.h[/URL]. So I get to use getch(), kbhit() et al. My problem is with kbhit(), is there no way of resetting it, so that I can reuse it? Aside : …

Member Avatar for DigitalPackrat
0
132
Member Avatar for DigitalPackrat

[code]class Customer { private: char name[50]; int acc_no; char acc_type; float balance; public: void getData(); }; int main() { Customer cust; cust.getData(); cust.getData(); } void Customer::getData() { cout<<"Name : "; cin>>name; cout<<"Acc No. : "; cin>>acc_no; cout<<"Acc Type : "; cin>>acc_type; } [/code] The second time I call the function …

Member Avatar for DigitalPackrat
0
141
Member Avatar for shotjase

Hey guys i have a header file and now i am writing the implementation file and defining the constructors..i am having trouble with 1 but.. void bitmap:save (string filename) { } //The bitmap representation is written to filename. The bitmap file will consist of two positive integers R and C …

Member Avatar for Ancient Dragon
0
92
Member Avatar for stevo356

Hi guys, I'm both new here, and new to c++ so be gentle! Over the past short time we've been looking at c++ on our course, but I don't believe it has been taught too well, and I'm struggling to understand what should really be basic concepts? An assignment we've …

Member Avatar for Ancient Dragon
0
125
Member Avatar for freakinsweet865

[code] double classAve (double g, int i); char gradeLet (double z); int main () { int ans, count = 0; double grade, numTot = 0; cout<<"Do you have a grade to enter? (Yes = 1, No = 2) "; cin>>ans; cout<<endl; while (ans != 1 && ans != 2) { …

Member Avatar for Ancient Dragon
0
99
Member Avatar for n3XusSLO

how do i use a function without calling it from a different class? (i have more files in my project) i made a test function called dostuff() { } inside some random file outside a class. but when i want to compile i get this: Error 1 error LNK2005: "void …

Member Avatar for n3XusSLO
0
279
Member Avatar for Black Magic

EDIT: I've got a while loop in my code, just now when player 1 goes to have his/her second attack the hp is reset to 99, [code=c++]#include <conio.h> #include <iostream> using namespace std; int main() { int p1attack, p2attack, p1hp, p2hp; char attack; p1hp = 99; p2hp = 99; system("TITLE …

Member Avatar for Sky Diploma
0
164
Member Avatar for popo_prince

i found this off some site and when i build it in vis c++, the errors are with the two random functions. will someone tell me why and how i can fix this. the random on line 15 and randomize on line 36. undeclared identifiers. [code] /* Jason Cordes */ …

Member Avatar for JasonCordes
0
148
Member Avatar for wiglaf

I was once trained in C and C++ and am now brushing off the cobwebs and relearning C++. I am restudying the Borland C++ Builder and realized I needed to know more C++, so I began restudying Visual C++...by Spencer and Perry. I am writing software to anazlyze lake water …

Member Avatar for vijayan121
0
399
Member Avatar for zawpai

Hi, Could anyone please check the following for me? I can't run it yet. Best Regards, zawpai

Member Avatar for zawpai
0
112
Member Avatar for DarkNet

I am having trouble implementing a sort function for this link list. This list works just fine. I just want to be able to sort by name. When I run the sort function I get back this; -------IN------- bb aaa aaaa aaaaa aa bbb b -------OUT------- bb bbb -------------- I …

Member Avatar for Ancient Dragon
0
85
Member Avatar for kylcrow

Ok so I am looking to read in a bunch of different types of data for a program, but I am having trouble doing so in a very robust way. For strings it's easy. [CODE=C++] string temp; getline(cin, temp); [/CODE] Simple and quite robust. For the rest I am having …

Member Avatar for Ancient Dragon
0
76
Member Avatar for hacker9801

Hey. I want to make a packet structure, something like [code=c++]struct Packet { int cmd; /* command */ int len; /* length of body */ char body[30]; /* body (should be length of len though, might use std::string) */ };[/code] Now, if I recieve some data thru a socket (I'm …

Member Avatar for hacker9801
0
111
Member Avatar for tones1986

Hey guys and girls. I am working on a project that needs to use templates. My professor didnt go over teh use of them in class, nor is our book very descriptive of them. Im assuming they are way easier than i make them seem, but some help , tips, …

Member Avatar for Lerner
0
148
Member Avatar for h0neydip

[code= cplusplus] struct wheel_node { int contents; wheel_node* next; }; typedef wheel_node* wheel_ptr; class wheel { private: wheel_ptr arrow; public: wheel (); void print (); void spin (int distance); void move_to (int number); }; [/code] The constructor wheel creates a circular linked list as follows: arrow -> 5 -> 40 …

Member Avatar for Lerner
0
147
Member Avatar for buddha527

I have the following code but every time I go to compile it i get the same 3 errors and do not know why I am getting them. I have tried googling why but can't really understand any explanations that I am given and therefore cannot fix the errors. Any …

Member Avatar for buddha527
0
100
Member Avatar for vesper967

Does anyone know a good site that gives source code of the implementation of a Splay tree with the balancing of the AVL tree?

Member Avatar for Salem
0
75
Member Avatar for Nemoticchigga

I am receiving over ethernet into a 'char messageBuffer[512]' and then passing it on by a function call to 'process((char*) messageBuffer)' then in process: [CODE] void process(char* theMessage) { myStruct messageBuffer; memcpy(&myStruct, &theMessage, sizeof(theMessage)); //this line is wrong } [/CODE] Im not sure how to properly put it back into …

Member Avatar for Nemoticchigga
0
64
Member Avatar for joshmo

Hey guys...i had an assignment i did last year and i had a problem linking the my files since the program was modularized..the lecturer accepted it with the errors since she also failed to figure it out..anyway i was scrolling through my work and today and i saw the code …

Member Avatar for joshmo
0
147
Member Avatar for Black Magic

Hey, i have made this little guessing game and was wondering how i could clear the screen every time to ask the question if the guess is wrong, though keeping line's 15 and 17 displayer all the time, i've tried but got msessed up programs etc, please help me adjust …

Member Avatar for joshmo
0
93
Member Avatar for cloudjc

[CODE]Hi Im completely new to programming and was wondering if anyone would be willing to help me with this exercise in C++. I have absolutely no idea how to do this exercise: ----------------------------------------------- Rational.h is a C++ header file which declares a class (Rational) which handles Rational numbers (i.e. fractions). …

Member Avatar for Ancient Dragon
0
431
Member Avatar for dinozulf

can anyone please help me with my program, my hand in date is on monday so i really need some help thank you

Member Avatar for Salem
0
171
Member Avatar for computers08

[code] int doubles (int d); int minimum (int m, int n); int oddEven (int a); int main () { int num, i, sum=0, num1, num2; for (i=0; i<5; i++) { cout<<"please enter a number. "; cin>>num; cout<<endl; sum= sum + num; } cout<<"the numbers added together is "<<sum<<endl; cout<<"the sum …

Member Avatar for Salem
0
95
Member Avatar for demroth

I have been reading older C programs to try and understand how to convert them to C++. One particular line of code still confuses me however. fscanf(fin, "%d", &n) I understand that fscanf reads from the stream (the file pointed to by fin), it reads the data which will be …

Member Avatar for demroth
0
150
Member Avatar for mbarriault

I'm trying to implement a very simple networking solution in C++. I've found a couple guides, but they all go far above and beyond what I actually need to do, so I figured I'd ask. I need to connect two computers. One computer will be broadcasting a (changing) integer on …

Member Avatar for Ancient Dragon
0
76
Member Avatar for Croft .L

Hi all! I just want to know a website or book that will start me with c++ programming. I have downloaded Microsoft c++ toolkit 1.01 2003 to start from so i have the place to start :!: Thanks!

Member Avatar for joshmo
0
131
Member Avatar for nurulshidanoni

How to do a selection sort? Which I want to sort in descending order this data 1 50 2 90 3 40

Member Avatar for Laiq Ahmed
0
90
Member Avatar for Cosa

I am trying to now multiply matrices stored in 2d arrays. When the program runs i get segmentation fault, using DDD i found the point where it stops after 3 loops. [code] int i,j,k; float** matrixc = new float*[rows]; if (matrixc != NULL) { for (int x = 0; x …

Member Avatar for Cosa
0
113
Member Avatar for qq9000

#include <iostream> using namespace std; int main() { const int NUM_NAMES = 20, Size = 17; char names[NUM_NAMES] [SIZE] = {"lonney, Bill", "travis, Jim", "Harrison, Bob", "Holland, Beth"}; i need a simple program that uses the selectionSort function so it searches an array of strings instead of an array of …

Member Avatar for Nick Evan
0
82
Member Avatar for Adrian99420

Hi, I created 3 combobox: comboBox1, comboBox2 and comboBox3. I wish to select the require combobox according to different case. I tried to use comboBo(i) but it return me error.For example, [code] for (int i=0; i=3;i++) { textBox1->Text=comboBox(i)->SelectedItem->ToString(); } [/code] The code return me error on selecting "comboBox(i)". I knew …

Member Avatar for Nick Evan
0
76
Member Avatar for Icetigris

I'm trying to write a data structure for a basic 3D engine, but for some reason it always crashes when I try to add an index to the polygon vector. Anyone know what may be going on? Thanks [code] #include <iostream> #include <string> #include <iterator> #include <vector> #include <gl/glut.h> #include …

Member Avatar for Laiq Ahmed
0
107
Member Avatar for chunalt787

I am trying to add sound into a whack a mole game for my C++ 101 class. I found this code on the internet [code]PlaySound("woofwoof.wav",NULL,SND_NODEFAULT);[/code] to add code and have it work the site says this: "It's defined in <mmsystem.h> and you have to link with winmm.lib." What does it …

Member Avatar for chunalt787
0
82
Member Avatar for David Wang

A simple array: int array[3]={1,2,3}; In GUI, I want to make the picturebox a element of an array, like: XXX array[3]={pictureBox1, pictureBox2, pictureBox3}; so what is "XXX"? By doing this I would like to control whether a pictureBox is visible or not, but the picturebox number depends on a changing …

0
62
Member Avatar for nurulshidanoni

How to declare the array and read the array? Must I use data structure? [U]Two array[/U] 1 30 2 20 3 10 4 50 5 15

Member Avatar for nurulshidanoni
0
104
Member Avatar for jimJohnson

I am writing a function and need to calculate the median...I am gonna b honest I absolutely have no idea how to start this but it is pretty much one of the last things I need to do with my program. Any advice would br greatly appreciated..... [code=c++] #include <iostream> …

Member Avatar for Ancient Dragon
0
228
Member Avatar for dpfaff

I cant figure out how to fix the errors in this prooram. Any help would be great. [CODE=cplusplus] // date: April 25, 2008 // username: dpfaff #include <cstring> #include <fstream> #include <iomanip> #include <cstdlib> #include <iostream> using namespace std; const int MAXCHARS = 25; const int MAXSIZE = 6; typedef …

Member Avatar for Ancient Dragon
0
134

The End.