C++ :: Executing Multiple Functions In Program
Mar 24, 2013
We have been assigned to create a program that uses multiple functions. The professor has given us code for two of the functions, one to open a file and then another one to read the files contents and output them. I have put these into my program but they will not execute. The program does run, but the functions themselves are not executing. I have practiced with other functions that contain no parameters and those run fine, but the functions she gave us have multiple parameters.
The code I have so far is below:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
void PrintFile (string FileName, ifstream& inFile);
int main () {
ifstream inFile;
string fileName;
[Code] .....
View 1 Replies
ADVERTISEMENT
Jan 22, 2013
I am getting an error on lines 31 and 36 about an expected identifier on my program that computes area and circumference. Is something wrong with my external functions outside of main?
Code:
#include <stdio.h>
#define PI 3.14159
double area;
double circum;
double find_circum (double radius);
double find_area (double radius);
[Code] ....
View 2 Replies
View Related
Feb 21, 2014
I already wrote a program that will calculate the gross pay for a set of employees.
I want modify the code by adding multiple functions.
I want to create a separate function whenever possible to break up the program.
For example, I would like have a function for obtaining the hours from the user, another function for calculating overtime hours, another for calculating gross pay and another function for producing the output.
#include <stdio.h>
#include <stdlib.h>
#define STD_HOURS 40.0
#define OT hour>STD_HOURS
#define SIZE 5
int main() {
int clockNumber[SIZE] = {98401, 526488, 765349, 34645, 127615}; /* employee ID */
[code]....
View 2 Replies
View Related
Oct 1, 2014
I am returning area from areaCircle(), but do not know how to print it in main. I know this program has lots of errors, two cases that I have listed.
Not sure how to properly list multiple function calls in a switch statement, and how to print one's return from main.
int main() {
char choice;
double area;
showMenu(choice);
switch (choice) // If input is C, use getRadius, areaCircle and count, then print the are
{
case 'C': void getRadius(),double areaCircle(), void count(bool display = false);
[Code]...
View 5 Replies
View Related
Apr 9, 2013
I have a Windows form application which has database and will store user details. my problem is while executing program form is not displaying .
View 1 Replies
View Related
Nov 25, 2013
Is there a way to tell the program to continue reading the next line of code within a nested IF statement?
The reason I want to do this is because the two "else" statements in the following sample (the main and the nested else) will contain the same exact code and I don't want to repeat it twice. I know I can do this by creating a function and calling it from each else statement but I was just wondering if what I'm asking is even possible without using a function.
if(1 < 2) {
// yes 1 is less than 2
if(5 > 10) {
// do something
} else {
// no, 5 in not greater than 10
// here is where I want to tell the program to continue reading the next else statement
[Code] ....
View 8 Replies
View Related
Apr 12, 2014
This code i made is a cent converter from 5 to 95 cents. The problem i'm receiving is when the 'cents' function is sent back to the 'main' function it only prints one line. It seems to just print the first if construct that complies with the statement. Is there anyway i can have this function print multiple cent values? For example if 60 cents was entered it would only print '50c', and i want it to print '50c' and '10c' instead.
Code:
#include <stdio.h>
int x;
void check(int x)
{
if( x < 5)
printf("Less then 5 cannot be calculated
");
else if(x > 95)
[code]....
View 3 Replies
View Related
Mar 15, 2013
I currently have globally declared arrays, which are accessed by multiple functions. I want to turn the program so that the arrays are no longer globally declared, but are passed to functions by reference.
I have one problem with passing the arrays: I found that, through debugging, I HAVE TO resize the array when I pass it by reference. For instance, I was using int a[10] when it was globally declared, when it is passed by reference with size 10, it does not work, instead it should be higher than 10 (certain number). Why is this happening? I do not get it...
View 6 Replies
View Related
Mar 15, 2013
Why this makefile only executes the first entry, compiling only the first program listed?
###########################################################
#
# Simple Makefile for Operating Systems Project 2
#
###########################################################
vowcon:
g++ -o vowcon vowcon.cpp -pthread
osproj2c:
g++ -o osproj2c osproj2c.cpp -pthread
osproj2b:
g++ -o osproj2b osproj2b.cpp -pthread
osproj2a:
gcc -o osproj2a osproj2a.c -pthread
clean:
rm osproj2a osproj2b osproj2c osproj2d vowcon
View 7 Replies
View Related
Oct 11, 2012
how I can run this as a separate process from the parent program, like a child process,
and return the result back to the parent program.
this script is as follows.
if file "/Stuff/s" exists then continue to run, if file "/Stuff/t" exists, then print "started" if file "/Stuff/t" does not exists, then print "stopped"
if file "/Stuff/s" does not exist then print "quit" and then quit.
Code:
void controlxmmscheck( ) {
if( access( "/Stuff/s", F_OK ) != -1 ) {
xmmscheck
} else {
[Code]....
View 1 Replies
View Related
Oct 16, 2012
I have this problem for an assignment, and one of the functions that I created for it is nothing fancy; just a function that'll take in a number and error-check to make sure the input is valid. However, after doing it, when the program calls that function, it skips the cin statement and ends the program, without letting the user input his number. The function in question is called getSubLength.
Code:
#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
using namespace std;
const string JANUARY = "January";
[code]...
View 2 Replies
View Related
Dec 9, 2013
in the below program for both class pointers pointing to null. Class contains normal function executing but class contains virtual function getting segmentation fault.
#include <cstdio>
using namespace std;
class A
{
[Code].....
View 1 Replies
View Related
Mar 4, 2015
I tried.
cin.get();
and
return 0;
is there a better way to keep the user info displaying without closing the console window.
View 1 Replies
View Related
Jun 15, 2013
PHP Code:
using namespace System;
ref class A {
public:
A(){Console::WriteLine(L"A constructor");}
virtual void func(){foo();}
void foo()
[Code] .....
Supposing that class A is the development code; and so for unit-testing purpose I create a mock for it. But I don't know how to override A's constructor such that it will not get executed in my unit-test code.
View 1 Replies
View Related
Nov 11, 2014
I am currently working on a c++ project that will input students and process their grades. I encountered a problem and my code stops executing after the getScores function. Im not sure what the problem is, but im guessing its something within the function and the loops.
//Name: getScores
//Description: Will get scores for student
//Parameters: None
//Return: testScore
double getScores()
[code]....
View 6 Replies
View Related
Jun 6, 2013
I need to make a program which can play a audio file as background while executing other operations .
View 4 Replies
View Related
Aug 18, 2013
i am trying to create a program for multiple windows. Here is my code
#include<Windows.h>
// Store handles to the main window and application instance globally.
HWND ghFirstWnd =0;
HWND ghSecondWnd=0;
HWND ghThirdWnd=0;
HINSTANCE ghAppInst=0;
[Code]...
problem is when i try to execute the code it just say create window1- failed!!
View 1 Replies
View Related
Dec 6, 2014
I'm writing a Blackjack program where the user can choose to Hit(H) or Stand (S). I would like them to be able to use upper or lower case letter for this. My code doesn't seem to work right for my Stands.
Code:
char choice;
do {
choice = 0;
while (choice < 1) {
printf("
[Code] ....
View 3 Replies
View Related
Apr 4, 2013
I need to write a program that will give me multiple calculation results.
#include <iostream>
using namespace std;
int main () {
int x = 8;
int y = 7;
[Code] ....
It only calculates the last two numbers: 1 and 0, so therefor it gives me 1.
But i need to calculate x and y each time they are smaller(incremented) by one digit.
Please note that the int calculation formula needs to stay.
View 2 Replies
View Related
May 31, 2013
I want to know how to read multiple text files in this program... I have 5 text files(order1,order2,...order5).
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<windows.h>
using namespace std;
class{
[Code] ....
View 3 Replies
View Related
Apr 6, 2013
I am looking at functions still and can't see the point in declaring the function at the top of the program, and then defining later i.e.
Code:
#include <iostream>
int add (int x, int y) {
return x + y;
[Code] .....
I obviously don't have much real world experience with this and am interested to see where declaring and defining later would be useful and/or beneficial.
View 14 Replies
View Related
Jun 16, 2013
Is there a program that can remove the functions in a program by preprocessing
Code:
#include<stdio.h>
int is_even(int number);
int main(void)
{
if(is_even(number))
{
printf("%d is even", number);
}
}
[Code]...
To something like
Code:
#include<stdio.h>
int is_even(int number);
int main(void)
{
if( number%2 ==0 )
{
printf("%d is even", number);
}
}
I use the "-E" option when compiling with gcc on linux but its output still contains funcitons. Is there a preprocessing program that can remove functions from a program?
View 6 Replies
View Related
Feb 26, 2013
when i am running this program no errors are being shown but as soon as i press ctr+f9 to run the program my tc++ window closes.....
Code:
#include<stdio.h>
#include<conio.h>
void multiply(int m1[50][50],int ,int,int m2[50][50],int ,int );
void main() {
int i,j,m,n,p,q,m1[50][50],m2[50][50];
[Code] ....
View 4 Replies
View Related
Nov 15, 2014
I have to make a numerical integration program, how I can write my code so that the user is able to write their own function that they want to integrate?
E.g. they would see the message: 'please enter your function' and would be able to write whatever they wanted e.g. 'x +5' then this would then be integrated by the program.
I have already written a program that can integrate a known function but would prefer that the user could choose their own.
View 2 Replies
View Related
Apr 12, 2013
I'm writing a program to check whether codes from a file are invalid, valid, inactive, or valid and active, but can't get it to work properly. The invalid codes are being found, but the other three are not. I think it may have something to do with my "active" function.
#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
using namespace std;
struct ActiveCodes {
string code;
bool flag;
[Code] ....
View 19 Replies
View Related
Nov 5, 2014
I want to make a custom program for packaging multiple files in one. Not as complicated as ZLIB or others. Consider few files, XML, txt, JPG, OGG, I want them to be added in 1 file. Not visible not readable. Just a datafile. I have some ideas about creating some kind of indexing of the start byte, end byte of each file. But I am still way too far. Can you point me some direction at what should I stress in creating this software. It will be portable since I am planning to use stdlib, stdio only, maybe and string to recreate the filenames from the large chunk datafile.
View 2 Replies
View Related