556 Posted Topics
Re: [QUOTE=tquiva;1211142]This is the error I get when putting "make miensfeld": cc -Aa -g -c -o main.o main.c <command-line>: error: missing '(' after predicate make: *** [main.o] Error 1 Does anyone see the error?[/QUOTE] No but since you left out most of the relevant information from the compiler error that is … | |
| |
Re: I'm sorry did you have a question or some compiler errors to post. Also putting code tags round your code makes it more easy to read. | |
Re: main returns int not void The actual error indicates that the linker was unable to find the main to link to the start-up code. | |
Re: The logic is to store digits rather than the whole integer. then you do addition in the same way you used to do it when you where 10 years old, one column at a time. Of course although you are storing digits you can choose the base to make effective … | |
Re: it is unlikely that it stores 0.2 as 0.259595 but it might store it as 0.2000001. Remember that a float is 4 bytes, it has the same unique number of combinations as an int (4 bytes), that is 4294967296. However a float can store "any" value in the range 1.175494351e-38F … | |
Re: Actually prism does not need to be a template. What it needs to do is store a [icode]shape*[/icode] that points to a shape that is the cross section of the prism. That would let you change the cross section if you wanted to. Note that this pointer should probably point … | |
Re: You appear to be trying to use TempBuffer to temporarily read a string before storing it. If you are reading a string from a file into a buffer how many dimensions does the buffer need? When calling fgets it is a really bad idea to give the buffer size as … | |
Re: When editing you need to reposition the file pointer to the beginning of the record you just read before writing, otherwise you overwrite the next record in the file. You will need to use fseek to do this. Additionally you program is leaking memory like a sieve, every time you … | |
Re: You mean that you don't know how to use cin to obtain user input to insert into your list or that you don't know how to insert data? BTW Account::insertNode is a disaster that in most cases will cause your list to corrupt. | |
Re: Then the thing to do is have a local char variable that you read the file into and then use a switch/if statement to decode the value into the actual value for employee[idx].pt | |
Re: [QUOTE=u8sand;1172185]Then your operator+ is simply: [code] BigInt& operator+(const BigInt&); [/code][/QUOTE]To preserve the correct addition (+) semantics and handle memory correctly operator+ has to return a object not a reference as do all binary operators also since it should not change the actual object it is called upon it can be … | |
Re: Line 14 - you use counter with initialising it to anything Line 16 - you modify numOfStars modifying the end condition of the loop in line 14 Line 18 - What??? Why do you think this is required? Line 20 - 3rd Nested Loop? You are printing out a 2D … | |
Re: Which line of your code reads the 19? What do you do with that 19 after it has been read? What will your code do if your professor decides to test it on a file containing 20 values? | |
Re: Well the initial thing to do is see if you can write down or actually catty out the process on paper. It needs to be something like [code] INITIALISE TRUCK LIST TO EMPTY CURRENT TRUCK = NEW EMPTY TRUCK FOR EACH ORDER IF THE ORDER WILL FIT IN THE CURRENT … | |
Re: @chiwawa10 you have miss-understood how std::find works and should be used and in fact you only have to look at the example in the page you have linked to to find the error. The end pointer should be a pointer to the first location just passed the end of the … | |
Re: Windows has no synchronisation exception, nor have I every seen an OS that did. If you share any data between 2 threads, including an std::string without guarding access to the data then you risk corrupting the data by simultaneous access which is likely to be bad for program execution. I … | |
Re: No because the size of datapixel will be in bytes and a mutiple of whole bytes | |
Re: Assuming the code compiles none of it will produce the correct results because you have not correctly implemented fractional arithmetic. Take operator+ [code] Fraction Fraction::operator+(const Fraction & fract) const { Fraction tempFract; tempFract.num=num+fract.num; tempFract.denom=denom+fract.denom; return tempFract; } [/code] According to this code then [code] 1 1 1 + 1 2 … | |
Re: You have = instead of == in your if statements. You only ever call [icode]rand()[/icode] once. You never initialise count. | |
Re: Why don't you just pass [icode]ostream &out[/icode] into your write function and write to the provided stream? | |
Re: In my opinion you are making things overly complex and attempting to introducing a style that is likely to just confuse anyone else trying to use the code you write which ultimately results in more maintenance overhead for no actual gain in functionality over [code] #include <iostream> using namespace std; … | |
Re: Calling scanf twice does not mean the user has to enter the data on more than one like. There is no implied reading of a new line character at the end of a scanf call. scanf just requires whitespace between fields which is space, tab, newline, carriage return but it … | |
Re: Try making c and int not a double. == and != really don't work well with double and float types because those types approximate values. | |
Re: You need to do your own work. Start by creating a program that will copy 1 file to another a byte at a time. Once you have that you can add filters to look for specific characters and output alternate character sequences as well as outputting extra text at the … | |
Re: You can't pass an actual array to a function but what you can do is pass a pointer to the first element of the array. In many ways a pointer to the first element can be used as an actual array for example [code] int array[5] = {5, 4, 3, … | |
Re: You are more likely to get your questions answered if you actually post them. | |
Re: Since the ifstream variable ListNumbers is only used inside the iblock of the if statement on line 51 if you declared it on line 52 instead of line 26 then there would be no problem you will have a new file object every time the user choose to open a … | |
Re: You could mess around with scaling your integers so that you only produce the required number of decimal places or you could just use the io manipulators from <iomanip> to format the output of the double value to only show 2 decimal places [icode]cout << fixed << setprecision(2) << SemesterGpa … | |
Re: Line 4 and 16 User_input is declared and used as accepting all [icode]double *[/icode] parameters but Line 24 [icode]void User_input (double *temp, double *mass, double *volume, double *Mmass, double Pc, double *Tc)[/icode] the 5th parameter Pc is declare [icode]double[/icode] not [icode]double *[/icode] | |
Re: Doing a sort to work out something like this is excessive (although of course over a handful of numbers the extra processing is probably negligible). A simple min routine will do the trick with the addition of an extra variable. Initialise min and the extra variable to the first element … | |
![]() | Re: When you instantiate a derived class before calling the constructor of the derived class (TwoDayPackage) it calls the constructor of the parent class (Package). Unless otherwise told it calls the default constructor so [code]TwoDayPackage::TwoDayPackage(const string &sn, const string &saddress, const string &scity, const string &sstate, int szipcode, const string &rname, … ![]() |
Re: Don't use tabs, you will always have that problem that way. Instead use the std::setw std::left io manipulators | |
Re: Just a couple of notes on how you have implemented your operators. Taking operator+ and operator+= as the examples but it applies to all the other ones too. Firstly because operator+= does in place addition it can return [icode]const Number&[/icode] rather than [icode]Number[/icode] which is more efficient as there is … | |
Re: under normal circumstances you can't do that. You can to set up some sort of communications link (a pipe or a shared file or shared memory, or a network link) between the programs and have them co-operate with each other in executing the required functionality. | |
Re: Did you seed the random number generator with [icode]srand()[/icode]? | |
Re: You should check that CreateFile returns success although you are presumably getting a sensible value returned from GetFileSize. You should check that ReadBuffer has been successfully allocated before trying to use it. You shouldn't pass a buffer size of BufferSize+1 to ReadFile when ReadBuffer is in fact only BufferSize in … | |
Re: stdlib.h is one of the C standard headers and contains quite a large and varied number of function declarations, the exact contents you can easily google. If you call a function without having first declared or defined it when it is defined somewhere in your program then in C you … | |
Re: Just thought I would mention the other direction. You have asked and talked about moving from the console onto GUI programming but there is another direction and that is leaving the user interface behind entirely or having a completely platform dependent interface. C++ (and C) are used on a vast … | |
Re: If you have a single chr that is a digit then converting it to a number is easy [code] char achar = '5'; int theint = achar - '0'; // theint now has the value 5 [/code] If necessary validate that the char is a digit using isdigit | |
Re: Have you created your own template classes BinaryHeap and PriorityQueue? What files are the code for those classes in? Have you included them into Main.cpp? | |
Re: Mixing cout and printf to output your results is a mistake. That 4 being output is the return value of printf, it printed 4 characters. Get rid of the printf and instead pipe [icode]count[c][/icode] staight to cout in the normal way. If you want to format the output read up … | |
Re: Line 8 of the sortQS.h you have posted [icode]recQS[/icode] is a member of [icode]UList<U>[/icode] but you do not call it on the object you call it as though it were a regular function try [icode]obj.recQS (0, obj.size()-1);[/icode] | |
Re: Why would you need a loop. Find the cube root of 40,000 [icode]pow(40000, 1.0/3.0)[/icode] call it R Find the first integer > R, I = (int)R + 1 Find the first integer >= I that is a multiple of 7, I += I % 7 BTW you have written [icode]pow(40000, … | |
Re: In your first code listing you are explicitly calling the destructors on many of your automatic scope objects, lines 18, 24, 37, 38, but that is completely unnecessary. The compiler automatically adds destructor calls for these objects so you destruct them twice. Since that is likely to involve a delete … | |
Re: [QUOTE=Blue$kull;1191809] [B]reciprocal.hpp[/B] [code] extern āCā { [/code] [/QUOTE] That should be [code] extern "C" { [/code] Shift-2 not whatever it is you have put in there. | |
Re: The reason that subject is not covered in any books on C++ is that there is no standard way to draw graphics or play sounds because C++ is a multi-platform language and graphics and sound hardware/drivers are platform specific. You will need a library but it will have to be … | |
Re: From winreg.h [code] #define HKEY_CLASSES_ROOT (( HKEY ) (ULONG_PTR)((LONG)0x80000000) ) #define HKEY_CURRENT_USER (( HKEY ) (ULONG_PTR)((LONG)0x80000001) ) #define HKEY_LOCAL_MACHINE (( HKEY ) (ULONG_PTR)((LONG)0x80000002) ) #define HKEY_USERS (( HKEY ) (ULONG_PTR)((LONG)0x80000003) ) #define HKEY_PERFORMANCE_DATA (( HKEY ) (ULONG_PTR)((LONG)0x80000004) ) #define HKEY_PERFORMANCE_TEXT (( HKEY ) (ULONG_PTR)((LONG)0x80000050) ) #define HKEY_PERFORMANCE_NLSTEXT (( HKEY ) … | |
Re: You never assign anything to the variable totAmt. The solution you are looking for is stated in the actualy question text you have posted [quote]Your program should pass these 3 arrays to a function named calc()[/quote] You are only passing 2 of those 3 arrays. Pass the 3rd one and … |
The End.