This code is for a program that allows you to play a guessing game or arithmetic game and shows your total score from both as you go along. The program works fine the only problem I'm having is with the score. Is there a way to call the score value from the outside function into main?
So trying to pass the value of score from the outer function int guessGame() into the score print statement in choice 3 of the main function? Oh and the "17 -turn_count" was just part of the requirements of the assignment.
I have a a group of text files that are used as input into a program. Another very similar program needs the same data in a different input format. I am writing a program that will read in each line of data and parse it. I have successfully written the program in main() such that it will read until the end of file. However, I am trying to re-write the program such that the algorithm is in an external function and will read one line at a time and then pass all of the character strings to the main program. The program will not compile and I am positive it has to do with an incorrect use of arrays in passing the variable "token". I am attaching a copy of the main program and the function.
I am getting a few compile errors for what might be a simple thing to do. I am opening a file in main, passing that pointer to a function and checking the contents of that file with a regex before I pass it on to build a BST. I am getting the following compile errors, what is wrong. Here are the errors:
Code: gcc main.c fileCheck.c -o tree main.c: In function `fileCheck': main.c:19: error: syntax error before "FILE" fileCheck.c: In function `fileCheck':
[Code] .....
Fatal error: Command failed for target `tree' Here is the two files and header that seem to be causing me the problems.
main.c
Code: #include "main.h" //#include "node.h" int main(int argc, char *argv[]) FILE *fp; if (argc > 2)
I have a 1wire program from maxim running in visual studio. There is this argument in the main function that requires the com port to be specified the command line. If I do pass it as "COM1" the program works as expected.
I don't want to depend on having to pass "COM1" in the command line and into main. I've tried creating a string for COM1 and passing it right into the if function but it doesn't work.
Code: int main(int argc, char **argv) { int len, addr, page, answer, i; int done = FALSE; SMALLINT bank = 1; uchar data[552];
I have a code in which I am passing string "5368709120" to function strtoull() and it should had returned me number 5368709120 but instead it returns me 1073741824 which is incorrect.
What may be the possible cause of this and how to rectify it?
Code: typedef unsigned long long ULL_Type; char *quotaStr = "5368709120"; ULL_Type quota; quota = strtoull(quotaStr, NULL, 10);
I have been assigned the following task and I am having difficulty in getting it to compile. The compiler is stopping at line 27 but I don't no what the error is.
The task is as follows:
Write two functions with the following function prototypes:
int my string len(char str[]) void my string cat(char dest[], char src[], int dest size)
Both functions should take zero-terminated strings as input. The first function should return the length of the string to the calling function. The second function should take a source and a destination string and the total size of the array pointed to by dest. It should then concatenated the source string onto the end of the destination string, if and only if the destination string has the capacity to store both strings. If the destination string does not have the capacity it should not alter either, print and error, and return to the calling function. Demonstrate the use both the above functions by using them in a program in which you initialise two character arrays with two strings, print out their length, print out the combined length, and print out the combined string
And this is my code so far:
/* A program to demonstrate string concatenation */
#include <iostream> #include <string.h> using namespace std; int my_string_len(char str[]){ // function to calculate length of a chracter array int len = 0;
I'm trying to pass the value of an object created from a class file to a function outside of the "Int Main" function in the main.cpp file. I've successfully created the object, I just want to pass it to a void function but I'm getting the scope error below. I'm not sure how to correct. I'm not having much luck with research either (static variables?).
Ok so I am working on a game and I'm in the process of developing my Player class. Anyways, what I have is a keyboard function that is called in my main function to make a shape move.
void myKeyboardFunction(unsigned char key, int x, int y) { switch ( key ) {
[Code].....
But when I try to call it, trying to copy my previous method,
glutKeyboardFunc(Player1.playerControls);
I get an error
error C3867: 'Player::playerControls': function call missing argument list; use '&Player::playerControls' to create a pointer to member
I get an error saying it can't convert parameters. I would just like to understand why the arguments become a problem when I make the function a member of my class, when the first method I used is so easy.
The function is supposed to return value from the file in my main, but I am getting empty value. I am trying to get better with pointer. Right now just teaching myself.
right now the only way for this code to show value is when in put the putchar(*ps) inside my readfile function. I would like to readfile to return value and print in the main function.
I am writing a program in which a Fucntion has to be wriiten to parse the Command Line . When I include Code for parsing in main fuction iteslf ,its run ok . But I want to make a fucntion of that code and call it from main ,than it show Segmentation error .
By using Debugging I found Some thing is mess with " -m" Parameter of Command line , But Cant Rectify it ..
Code: int main (int argc, char *argv[]){ //get_parameter_value(argc,argv); // buffer[packet_size+1]= char ("'"); while (argc > 1) { if (argv[h][0] == '-')
int example (int [], int, *int,*int,*int,*int); int main () { My code will be here example (int array[], int size, &a,&b,&c,&d); // Like this??? I try it didnt work
#include <iostream> #include <string> #include <ctime> // to use the time function #include <cstdlib> using namespace std; int getUserChoose (int);
[Code] ....
here is the output
Welcome to the program of Rock, Paper, Scissors The computer is ready to play the game Are you ready to play the game Y for yes and N for no Y R = Rock; P = Paper; S = Scissors R You have choose Rock 1TN 1RM 0U 0C
I'm currently writing a poker game and am trying my best to avoid using global variables. I have a few variables in int main() which i was hoping to use to store the value of each players hand. I then created a function which calculates the value of the hand but cannot get this value back into the main function.
For example:
Code: #include <iostream> using namespace std; void getValue(int value) { value = 4;
[Code] ....
Is there any way i can get the value of value using this function? If not what can I do?
I am just practicing some recursion and I am having trouble with printing out a recursive function in main. Here is what I have:
Code:
// This function adds the squares 4, 5 = 4*4 + 5*5 recursiveley int recursive_sumSquares(int m, int n) { if (m < n) { return m*m + recursive_SumSquares(m+1, n); } else { return m*m;
[Code]...
I am getting an error that says undefined reference to 'recursive_SumSquares'
I have i want to call a function with two results for example x = 1 and y = 2.How do i return this function in c and how do i call such a function in the main program.
But how to define a shape (say a circle by that cir() function which is) outside of the main() function? And how to attach it to be visible on window win?