49,761 Topics

Member Avatar for
Member Avatar for sgw

In the following very simple program, if the input is [I]not [/I]an integer (e.g. a character symbol), then the output screen would flash and go away. Is there a way to have the output "bad" when one enters a non-integer, just as when one enters a negative number? Thanks in …

Member Avatar for sgw
0
251
Member Avatar for Brandon515

hey guys, ok here's the situation. i need to turn a C++ style string into an integer now i've used altoi and strtol but they give me different numbers. heres my code [CODE] cout << file << endl << file.c_str() << endl; // debugging purposes num = strtol(file.c_str(), &pEnd, 10); …

Member Avatar for Brandon515
0
128
Member Avatar for blackst0rm

I am using Visual C++ Express Edition. I have 3 files: (A) main.cpp, (B) prototypes.h (C) implementation.cpp. main.cpp includes prototypes.h and prototypes.h includes implementation.cpp. When I go to "Start without debugging" things screw up because in (C) implementation.cpp the compiler complains that it can't find the data fields. e.g. it's …

Member Avatar for Ancient Dragon
0
258
Member Avatar for suganthan901307

[code=c++]#include<iostream.h> #include<conio.h> void main() { int x[5]={1,2,3,4,5},y[5]={5,4,3,2,1},result [5]={0,0,0,0,0}; int i=0; while(i++ <5) result[i]=x[i]-y[i]; clrscr(); cout<<"\nThe contents of the array are :\n"; i=0; do { cout<<'\t'<<x[i]<<'\t'<<y[i]<<'\t'<<result [i]<<"\n"; i++; }while(i<5); getch(); }[/code] OUTPUT: The contents of the array are: 1 -1 0 2 4 -2 3 3 0 4 2 2 5 …

Member Avatar for Ancient Dragon
-5
117
Member Avatar for jsmarts

my assignment is to make a triangel like so: * ** *** **** ***** I have done so but cannot get my command window to stay open. It pops up and closes right back out. heres my code can anyone help? #include <iostream> int drawBar(int); int main() { std::cout << …

Member Avatar for Shinedevil
0
147
Member Avatar for djnstuff

Okay, what I'm trying to do here is set up a some-what simple battle system for a text based game... I'm having some trouble getting it to work correctly though. I want the Player's attack and the Monster's defense to be random each time the program loops (which is also …

Member Avatar for Shinedevil
0
320
Member Avatar for restrictment

Hello, I am trying to make an rpg, and I am having troubles with functions. I am currently working on the 'potion' aspect of my rpg, which I have highlighted in red. My question is this: Is it possible to make the function return money, potion number, potion size, etc? …

Member Avatar for restrictment
0
373
Member Avatar for kadji.kahn

I'm trying to make a program that will read two txt files, with GPA information (one for females and one for males) arranged like this: M 4.0 M 3.7 M 2.9 I've been instructed to used pass by reference void functions with no global variables. My major issue is how …

Member Avatar for kadji.kahn
0
172
Member Avatar for Shaitan00

My system has a service (Serv.exe) which starts as LocalSystem and should be running at all time, additionally on startup of the PC (auto logon) the user has a STARTUP application (App.exe) which runs. Sadly I've found that sometimes App.exe starts to run before Serv.exe has finished starting, and one …

0
112
Member Avatar for skarocks47

So i am just starting out learning C ++ and i was trying to make a BMI calculator. When ever i run the program and it prints the BMI number its a weird number. Not one it should get. Please can u help me out with my source? #include <iostream> …

Member Avatar for jonsca
0
190
Member Avatar for asxoliastos

Hello I am new to this forum so be patient.. I am currently having an issue with a map iterator well the code i am talking about: [CODE] leafnode<LeafEntry<recno_t> ,blocknum,char*,recno_t>* descend(Object<dimensionality,Type>& ob,nonleafnode<NonLeafEntry<dimensionality,Type>,dimensionality,Type>* rt,blocknum* leafblocknum){ std::map< int,NonLeafEntry<dimensionality,Type>* >* entries; std::map< int,NonLeafEntry<dimensionality,Type>* >::iterator it; leafnode<LeafEntry<recno_t> ,blocknum,char*,recno_t>* L; int i,elements; if(rt == NULL) …

Member Avatar for asxoliastos
0
131
Member Avatar for tararengan

hello, I am interested in implementing the push relabel max flow algorithm in C++. I see an implementation at [url]http://www.boost.org/doc/libs/1_40_0/libs/graph/doc/push_relabel_max_flow.html[/url] and don;t understand a good bit of it. I am in a position to describe my graph and if someone could explain how I can use this piece of code, …

0
84
Member Avatar for rkulp

I am trying to overload the Comparison Operators, to have them compare the RMR of two fitness trackers. I need to change the RMR from a double to an int for the comparison. How would I do this when the RMR is calculated by a function. Here is my code. …

0
111
Member Avatar for AdRock

I have a string which i can break down into tokens but what i want it to do is if it reaches a '//' it breaks out of the loop so no more tokens are added I have tried using this but it doesn't work [CODE]while (p!=NULL) { if(p=="//") { …

Member Avatar for AdRock
0
176
Member Avatar for xfreebornx

How can i sort this array pls.. [CODE]#include<iostream> #include<algorithm> using namespace std; int prompt(int x[]); void printreverse(int x[]); int main() { int x[5]; prompt(x); printreverse(x); system("pause"); return 0; } int prompt(int x[]) { for(int i=0;i<5;i++) { cout <<"Enter integers:"; cin >>x[i]; } } void printreverse(int x[]) { for(int i=0;i<5;i++) { …

Member Avatar for mrnutty
0
112
Member Avatar for teddyg18

So i am writing a simple prgm in which you enter the values of 2 matrices and multiplies them. [code] #include<iostream> #include<iomanip> #include<cmath> using namespace std; int main() { int i, j , k , l, m , n , o, p; cout<<"Enter The Rows And Cloumns And Of The …

Member Avatar for asxoliastos
0
122
Member Avatar for RonW56

Can someone help me with this problem I've been trying to do an else statement but it doesn't work here is the code.... for(int c=0;c<student_max;c++){ if(search_id==id[c]){ location=binary_search(id,student_max,search_id); cout<<"Student ID \tTotal \tGrade"<<endl; cout<<"-----------------------------"<<endl; cout<<search_id<<" \t\t"<<total[location]<<" \t"<<determine_grade(total[location])<<endl; //break; } //} else{ cout<<"Incorrect id entered"<<endl; break; } } }

Member Avatar for boblied
0
115
Member Avatar for rookanga

my assignment says to "Finish the header block on the function. " What is the header block? Is it the // (write information) or is it something else?

Member Avatar for Fbody
0
124
Member Avatar for isabellegagnier

I need to create a triangle in C++ that will take the user inputted letter (capital) and then create a triangle that will look like. I can only use nested loops NO arrays or strings Enter a letter: F F FE FED FEDC FEDCB FEDCBA here is the code i …

Member Avatar for isabellegagnier
0
229
Member Avatar for gtrippleb

I'm trying to write a c++ program that first asks how may people are in a party, then it takes that number to calculate how many times to ask what the next person wants to order. This is what I have so far. I can get the program to recognize …

Member Avatar for gtrippleb
0
113
Member Avatar for discovery-power

Hi All, I am trying to write a small program to better understand and practise writing blocks of code, I have written the one below but get the error message : "Linker Error undefined reference to WinMain@16 ld returned 1 exit status" // This program demonstrates a block of code …

Member Avatar for Fbody
0
128
Member Avatar for gedas

Hi everyone, Well I come to a point that I have run out of ideas and time and I’m going to ask for help from anyone that can help. I hope that there will be someone that could give me a hint how to solve my problem. About my problem …

0
92
Member Avatar for abraham james

May somebody pliz help explain to me line by line of this c++ coding cause I can't seem to understand it:- #include <stdio.h> #include <stdlib.h> #define SIZE 50 #define pi 3.14 void push(int i); int pop(void); void sort(int stack[SIZE],int numbers); int *pointer, stack[SIZE],numbers; void main(void) { int value,numbers,num,num2,num3,num4,array[5],num6,num7,num8; float num5,num9; …

Member Avatar for William Hemsworth
0
214
Member Avatar for Kaotic07

Hello, I have to write a program that merges 2 seperate files and then outputs to a single file. Each input file is to have numbers in ascending order and the output is supposed to compare these and then put them in ascending order. ex.: input1 = 1 3 5 …

Member Avatar for Kaotic07
0
149
Member Avatar for nalasimbha

I have the following struct [CODE]struct A { int a, *b, *c, *d; };[/CODE] I would be creating an array of A and then populating the member variable for each of struct in the array. The members b,c,d are allocated dynamically based on the value of A.a. To assign the …

Member Avatar for VernonDozier
0
108
Member Avatar for guguman

Hi guys, Sorry to ask a question as my first post. I'm totally new with c++ and I couldn't understand much about vectors. [CODE] case 1: { cout<<"Enter [S]avings Account , [C]hecking Account,[G]eneral Account"<<endl; cin>>selection; if ((selection == 'G') || (selection == 'g')) { acc.push_back(newAccount); cout<<"New account added"<<flush<<endl; break; }//end …

Member Avatar for SVR
0
139
Member Avatar for Excizted

Hi. I have a problem I cant find a solution to, since I am unable to describe the problem in a searchable way. I make a hWnd for each contact the user has: [CODE=C++]contact[atoi(rowC[0])].hWnd = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG4), hWnd, messengerBox);[/CODE] messengerBox is defined like this. [CODE=C++]BOOL CALLBACK messengerBox(HWND hWnd, UINT message, …

Member Avatar for Excizted
0
429
Member Avatar for UKmason

[CODE]double distance (double angle, int mps, double earth_gravity) { double earth_distance; double speed_sqr = mps * mps; earth_distance = speed_sqr * sin(2*angle) / earth_gravity; return earth_distance; }[/CODE] its supposed to come out at = 3831.57 intead it ends up being =3155.52 anyone know what im doing wrong?

Member Avatar for Fbody
0
267
Member Avatar for discovery-power

Hi All, I have just started learning how to write C++, I have written my very first very simple program using notepad and saved the file as simple.cpp. So my question is how do I compile or build my program into an executable file, I understand I have to use …

Member Avatar for discovery-power
0
158
Member Avatar for discovery-power

Hi All, I am currently learning C++ and i have started to write some small programs that explain operators, integers and values, my question is this. How do I make my programs stay on screen, at the moment I run my program it displays the message on screen for about …

Member Avatar for discovery-power
0
162

The End.