1,608 Posted Topics

Member Avatar for jcflore3

The variables num and num1 in the display function are not declared. That's what the compiler is complaining about. Instead of ch = getche() I'd use cin >> ch; since this is C++. You have declared and defined noPayCar() as taking an int but don't pass it anything in main() …

Member Avatar for may4life
0
231
Member Avatar for noople

For practical purposes if w is declared as char w[1000]; then w can only hold 1 string. If you want w to be an array of strings, then you want this: char w[x][y]; or one of these: char ** w; char * w[x]; where x and y are positive constant …

Member Avatar for noople
0
2K
Member Avatar for NSta

Thanks for the code tags, but use of indentation would make the code a whole lot easier to read! Per your instructions the copy contstructor in your third post looks appropriate, though you'll need to declare and define the createCopy() functions somewhere. I suspect that the createCopy() functions should be …

Member Avatar for NSta
0
130
Member Avatar for aznballerlee

In C++ the only way you can allocate memory on the fly is with the new operator. If you don't see the keyword new anywhere in the code, then no dynamic memory is allocated. Static memory is allocated any time you declare an object or a function. The amount of …

Member Avatar for John A
0
147
Member Avatar for Acquire

Debugging a program is almost always the hardest part. Since you never use the file pointer in main() you can eliminate it. Since currentplayer isn't passed to showPlayerData() or totalAverage() it can be declared local to fillStructure() and passed to ValidateData(). I don't see where results of search() is ever …

Member Avatar for Lerner
0
106
Member Avatar for Sin-da-cat

Read all the lines into a container in your program. Sort the container. Then write the contents of the container back to your file, overwriting the previous unsorted contents of the file. What container you use is up to you based on your knowledge and experience. What sorting algorhythm you …

Member Avatar for vegaseat
0
387
Member Avatar for Gunner54

The compilers I use will take you to the potential culprit line. If yours does too then telling us which line is pointed to gives us, and you too, an idea of where to start. Since: BYTE godmode[] = {0x90, 0x90}; and this: BYTE godmode[] = {0x7B, 0x05}; are both …

Member Avatar for Lerner
0
95
Member Avatar for boujibabe

[code] that can get tedious [/code] Sure it can. But so can keeping track of where the file pointer is and what state is in. Just passing the file pointer to the file doesn't gaurantee the file pointer is in a useable state/position. For example, if you read the entire …

Member Avatar for boujibabe
0
332
Member Avatar for rbinc

You can check the fail state of the stream to assist with type validation rather than accept input as a string, validate, and convert if necessary. It's no simpler than the other version, but it works. [code] 1)declare variable int k = 0; 2)attempt input std::cin > k; 3)check the …

Member Avatar for Lerner
0
221
Member Avatar for Gunner54

[code] int function(int val) { int rtn; if (val > 10) { int tmp = val * 4; rtn = tmp + val; } else { tmp = val * 6; rtn = tmp - val; } return rtn; } [/code] In this version of WaltPs example rtn is visible/available …

Member Avatar for WaltP
0
168
Member Avatar for pedz

For what it's worth, and it may not be worth much, here's my thoughts. In the top example NS is a namespace, like namespace std is a namespace, and T is a class, like any other class. The scope operator tells the linker/compiler to look in the NS namespace for …

Member Avatar for Lerner
0
115
Member Avatar for JRM

As a hobbyist I find the convenience of an IDE to be wonderful. I don't have to fuss with command line arguments, makefiles, linkers, etc. From what I can tell compilers, makefiles, linkers, etc. seem implementer specific and not part of the language itself. The analagy I use is that …

Member Avatar for nanodano
0
148
Member Avatar for mattyd

>>Now I would really like to know who writes functions that way !!! Placement of the opening curly bracket on the same line as the function definition or the loop control is a standard style. I believe it is used in such notable references as K&R and from past discussions …

Member Avatar for vegaseat
0
323
Member Avatar for pointers

Here's a rough algorhythm, based on my understanding of the problem as stated and what is done in a binary search of an array of sorted items, that may or may not be useful. 1) Break the input string into three separate substrings representing day string, month string and year …

Member Avatar for Bench
0
109
Member Avatar for batista06

[quote] I'm trying to turn this part into a function into my code [code] grosspay = (hours * rate); if (hours > 40) grosspay = ((hours - 40) * rate * 1.5) + (40 * rate); if (hours > 60) grosspay = ((hours - 60) * rate * 2) + …

Member Avatar for Ancient Dragon
0
126
Member Avatar for mikeallen

Complex( double = 0.0, double = 0.0 ); // declaration of constructor taking two doubles as arguments, each argument defaulting to 0.0 if no parameter passed in. Complex() : real(0.0), imaginary(0.0) {} //declaration and definition of default constructor setting real and imaginary data members to 0.0. No arguments can be …

Member Avatar for mikeallen
0
146
Member Avatar for JS1988

Take a pencil and paper and write out what your for loops are doing and see if it sounds like what Ancient Dragon posted. The second program requires two nested loops. The body of the inner loop can use an if/else statement to determine what to display where. I suspect …

Member Avatar for may4life
0
123
Member Avatar for jimbobint

Think of the ++ operator as just another method of the class, like getItsVal() and setItsVal(). Instead of ++ another method of incrementItsVal() could have been written like this: const Counter& Counter::incrementItsVal() { ++itsVal; return *this; } and used like this: Counter i; i.setItsVal(1); i.incrementItsVal(); In theis case using the …

Member Avatar for jimbobint
0
322
Member Avatar for orko

1) What's the terminating condition of the for loop? 2) If I have APA and I want to remove the first A then I can store the head in a temp node, change head to to head->next, then delete the temp node. However, if I have APCP and I want …

Member Avatar for Lerner
0
131
Member Avatar for gwinera

First, I found a number of errors in the code as written: 1) Instructions say isSentEnd() is supposed to be sent a single int as a parameter, not a char array and an int. 2) int c, i; if (c==EOF) return(false); c is not initialized before the == operator is …

Member Avatar for gwinera
0
92
Member Avatar for matrimforever

>>I should be reading in only 3 lines for 3 calculations C++ does allow you to read in a whole line at once, including all spaces and other whitespace characters, delimiting on any given char---which is the newline char by default, though you can make it any char you want. …

Member Avatar for matrimforever
0
168
Member Avatar for phuduz

The number of parameters in the Display() function definition doesn't match the number of parameters in the Display() function declaration. Too many commas there. Redo the definition and recompile. N.B. next time try putting a / before the word code at the end of your code when using code tags. …

Member Avatar for phuduz
0
96
Member Avatar for kissiwat

the age restriction applies to each sprog, so the check needs to be placed in appropriate relation to the age variable. [code] do printf enter an age between 5 and 7 scanf age while age < 5 or age > 7 age1 = age [/code] repeat for age2, age3 and …

Member Avatar for Lerner
0
142
Member Avatar for ReDeViL
Member Avatar for ReDeViL
0
137
Member Avatar for taruj83

The first thing you need to do is to be sure you understand the problem and can express it in your own words. Here's an example. Accept input as a string. The string will represent an expression. The expression input will be terminated by a semicolon. Once you have the …

Member Avatar for iamthwee
0
98
Member Avatar for nono909

If you're allowed to use the STL list class this assignment should be relatively straightforward. #include<list> #include<string> #include<iostream> std::list<std::string> listOfStrings will get you a list of std::strings std::list<int> listOfInts will get you a list of ints, etc. Displaying the information stored in each node/link of the list requires that you …

Member Avatar for iamthwee
0
87
Member Avatar for kimw

You could consider the find() or find_first_of() algorhithms or you could consider a map or multimap structure instead of a vector.

Member Avatar for Ancient Dragon
0
99
Member Avatar for matrimforever

We can debate whether declaring the constants globally or local to main() until we're blue in the face, and we won't be right or wrong. Since this is an excercise in passing parameters, however, I would argue to make the constants local to main() and pass them as needed to …

Member Avatar for ~s.o.s~
0
170
Member Avatar for micmac700

>>how can I develop a queue struct atop of the program that allows me to make instances of queue.c? This phrase: instances of queue.c, is probably more correctly stated as: instances of type queue. That's because queue.c is a file that contains information about how the user declared queue type …

Member Avatar for Lerner
1
443
Member Avatar for bg123

mynumb = inFile.get(); ????????? array[j][i]= mynumb; Try changing the above to inFile >> array[j][i]; and looking up the difference between the behaviour of get() vs >>. They both have their uses.

Member Avatar for Lerner
1
128
Member Avatar for amano

I would encourage you to do just one function at a time. Since your first function is Add(), I would comment all the other functions bodies and just have a statement like printf("in Del()"); etc. until you get there. Within Add() I would note: 1) each keyword do needs a …

Member Avatar for Dave Sinkula
0
1K
Member Avatar for viki

You could try looking for a math library that already does this. There is no straightforward way of doing this yourself.

Member Avatar for DavidB
1
707
Member Avatar for linq

Post withdrawn in deference to post from Ancient Dragon. Don't see a delete button, darn.

Member Avatar for Ancient Dragon
1
66
Member Avatar for aaholland

Not being familiar with whatever curses is I still have a couple concerns with the code as posted. First, main() should be declared with a return type, just like any other function. That return type should be type int to be standard, though implementations of some compilers allow you to …

Member Avatar for ~s.o.s~
1
98
Member Avatar for hygy486

As much as you may not like to hear it, you've been given good advice. Essentially you have four choices: 1) Use ASCI art (use what characters are available in the ASCI character set). It will probably help to have an ASCI table to look up the available characters and …

Member Avatar for Ancient Dragon
2
204
Member Avatar for the.future.zone

case 1: The above means if the input is the integer 1 case '1' : The means if the input is the character one, not if input is the integer 1. Note the single quotes around 1 not present in the first line of this post. Perhaps this would be …

Member Avatar for Lerner
0
166
Member Avatar for brianotieno

FILE * fm = fm.1; This line contains the first declaration of fm that I can see, as an instance of the type FILE *. However, fm.1 implies that there is a struct callled fm some place and you want to initalize the FILE * called fm with the value …

Member Avatar for Dave Sinkula
0
335
Member Avatar for l-o-s-t

One concept that works no matter what base you are using to do the math is to realize that you don't do the arithmetical operation on the whole string/number at once, rather you do the arithmetical operation on(one or) two ints at a time. So you somehow need to change …

Member Avatar for Grunt
0
125
Member Avatar for puuukeey

change this: *line++; //point *line to the next array element to this: line++; //point *line to the next array element line is the pointer. *line is the value at the address being held in the pointer. You want to advance the pointer to the next element in array, not the …

Member Avatar for Dave Sinkula
0
155
Member Avatar for freesoft_2000

The >> will stop input into the desired variable at the first white space char it encounters. Whitespace characters include the space, tab, and newline char in addition to EOF indicator. getline(), whether the version for C style strings or the version for STL strings won't stop at any whitespace …

Member Avatar for Lerner
0
161
Member Avatar for taha54

We really don't like to write whole programs or routines for people. Here's a quick overview with a little more detail than p;rovided by Grunt. As you can tell, there are several choices you will have to make depending on what you know and don't know. The phrase you are …

Member Avatar for WaltP
0
1K
Member Avatar for sgriffiths

You use the dot operator to refer to a specific member of a struct straigtup and the arrow operator to refer to a specific member of a struct if you have a pointer to struct instead of the struct itself. List[100] is an array of type s_list. To pass a …

Member Avatar for ~s.o.s~
0
691
Member Avatar for faizalw

[quote] how can I make the input limited to one char? [/quote] Declare a character variable to hold the input. Use >>, or its equivalent in C, to accept the input. Flush the input buffer to remove anything else the user entered. [quote] If I work with number only, how …

Member Avatar for Lerner
0
111
Member Avatar for sgriffiths

You will have to sort all the information you want to print out before you print the information. Obtain all items to print. Sort items to print. Print items. The process that does the sorting can be any of a number of protocols including bubble sort, quick sort, insert sort, …

Member Avatar for dwks
0
142
Member Avatar for Treant

Pare back the program to a single method within the class and compile that, then add methods back one at a time making sure each one compiles as you go. When it no longer compiles, you'll have a good start at where to look. Alternatively, pare back one method at …

Member Avatar for Salem
0
110
Member Avatar for mitchelltab

Start with restatement of instructions, like this: [code] //I need to use these header files to do what I want //the following values are defined as constants //At minimum I need to use these functions: Read one student’s classification Compute one tuition Compute the low/high/average tuition paid Write one result …

Member Avatar for Dave Sinkula
0
187
Member Avatar for hiphoprules

The mechanism to create the string (word) frequency counter depends on your project requirements and your current knowledcge base. If you know the number of unique strings that can be associated with any given value of da, then you could use a static array of type struct where the struct …

Member Avatar for hiphoprules
0
127
Member Avatar for vicky_dev

Here's what I think happens. [code] STRING s1("String1"); //string constructor called STRING s2("String2"); //string constructor called STRING s3; //default constructor called s3 = s1+s2; //default constructor called within the + operator //copy constructor called by compiler to create temporary object from res returned from + operator //destructor called to remove …

Member Avatar for WolfPack
0
405
Member Avatar for tefflox
Member Avatar for rapt0r

or maybe: [code] #include <iostream> #include <string> string name("mark"); //this is initialization, not assignment int main() { cout<<name; return 0; } [/code] However, I don't think you can assign values to global variables outside of a function.

Member Avatar for ~s.o.s~
0
196

The End.