1,426 Posted Topics
Re: Please refrain from name calling. Salem is a great poster and has some very good advice. you did not post any code or say what this is for so even i though it was asking for homework help. it is best to clearly state what is going on becuase we … | |
Re: good news is that if you have to write it in a switch statement you can use the drop through method eg [code=c++] switch (score) case 99: case 98: // so on case 90: //display info break; case 89: case 88: // so on case 80: //display info break; case … | |
Re: @ ookamioni The problem OP is having is he is trying to make a win32 app work as a win32 console. In a console you generally have int main() not WinMain(). He is not missing a ";" anywhere. | |
Re: a lexer is a program that runs through text and converts it into something you can use in your program an example would be a program that lets you input something like 5x^5 - 3x^3 + 20x^2 +5x -15. it would convert all of those into tokens that your program … | |
Re: Here is a good link for you. [url]http://www.cppreference.com/wiki/stl/algorithm/transform[/url] If you cant figure it out still let me know. | |
Re: im not seeing a [icode] #include <iostream> [/icode] anywhere. | |
Re: Look at line 70. Notice anything particular about it? Also line 98 is wrong. Your instructions say to calculate the average of the 3 highest scores to the nearest integer. Does a double qualify as an integer? These are some things for you to look at. Remember it is better … | |
Re: just use an if statement and if counter is equal to zero use setprecision 0 for your variables. | |
Re: Could you please post your error meesages. Also on line 43 in your do_add() function you are doing [icode] sum = num1 + num2; [/icode] You can not do something like this since they are arrays. You would have to write a function to step through the array and add … | |
Re: i striped down your function just to walk it through my debugger and i had to change [icode] char ch; [/icode] to [icode] unsigned char ch; [/icode] in order to get it to work. what was happening was it was using a signed char which has a max value of … | |
Re: where are you outputting the data to the file? i have never seen it done with using the iterator normally in the while loop you should have a line like [code=c++] // in while loop fout << v1[i] << "\n"; i++; [/code] | |
would the workings of strlen() be something like this? [code=c++] int strlen(const char * str) { int size = 0; while (!!*str) size++; return size; } [/code] any feedback would be appreciated. also i have learned that !! will convert a value to an actual bool eg. !!104 = 1 | |
Re: according to my MSDN you should use [icode] srand((unsigned)time(0)); [/icode] | |
Re: you are not assigning the return from s.pop() to anything. also please use code tags | |
Re: why exactly are you passing an array to your collision method? wouldn't you just want to pass one object or are you trying to see if everything in that array will collide with the calling object? | |
Re: the problem is you are using gets() for your input and when you enter more than 10 elements the function gets() writes pass the end of the array and is casing your problem. you can make s bigger then see if s is larger than 10 and if it is … | |
Re: functions return a reference so that there is less overhead in the function return. whatever value you store the return into will hold that value and it doesn't matter that the variable that was returned goes out of scope. [code=c++] // non reference return int foo() { int a = … | |
Re: the problem is when you pass an array to a function the actual thing that gets passed is a pointer to the first element of the array. the function doesn't know its an array so it doesn't know that he address after the pointer are part of the array. there … | |
Re: i would take a closer look at your variable names. | |
Re: lines 7 and 17-20 need to be looked at again. there is where some of your errors are coming from. | |
Re: i believe i have a solution to your problem but there are more values in your sorted results than in the text file with the information to sort. for example there are two "b5"'s in your sorted results but only one in the text file. please let me know because … | |
Re: the faster the data can enter and leave the the ram the better your computer will perform. i.e. a 3ghz processor with 400mhz ram will run slower putting information into the ram than a 1ghz processor with 1ghz ram | |
Re: you are getting a overflow and that is what the return value becomes. your call to pow when k=10 for instance returns 1.5556504132421497887188538979512e+174 but the max value for a float is 3.40282e+038. i would try using type double which has a max of 1.79769e+308. | |
Re: To EngSara and gertails please read this [url]http://www.daniweb.com/forums/announcement8-2.html[/url] . This forum is designed to help people find answers not to give them to them. This was assigned as homework for a reason. People must show effort otherwise the learning process does not happen as it should. | |
Re: To jBat and invisi I would reconsider your input methods. you are using [icode] cin >> val; [/icode] which will cause an infinite loop to occur if if something other than a char is entered. I would suggest the use of [icode] get(cin, val); [/icode] instead and then convert if … | |
Re: [icode] if (answer!=df1/df2) [/icode] Very scary. You should not compare floating point numbers this way because it will not always work. here is a good link on why. [url]http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.17[/url] | |
Re: [code=c++] #include statements using statements global vars ie ofstream fout; or ifstream fin; function prototypes int main() { //... [/code] this is the style i use | |
Re: to dived you use / not \. also i(...) is not valid. if you want to multiply i by that quantity you have to do [icode] i * (1.0 / i) [/icode]. Also please use code tags. the link to explian them is [url]http://www.daniweb.com/forums/announcement8-3.html[/url] | |
Re: well first of your calling getline twice. once after your for statement and once after your if statement. also you should not use eof() while reading to the end of the file. you can search around and find some good links about that. i would get rid of the for … | |
Re: well since some one already kicked the dead horse ill join in. the guy is looking for the cubed root of a number. lets say its 27. the answer would be 3. now lets say its -27. it would be imaginary right? wrong it exist. if you take -3 and … | |
Re: srand() seeds the rand() function. a good way to get a random seed is to use the time function because it changes every time you use it. it should be used as follows for general uses [code=c++] //... srand(time(NULL)); value = rand() % 365 + 1; //... [/code] you will … | |
Re: where are you getting the isblank() function from? | |
Re: In the state of the economy right now what is the least amount of education a programmer should have before even trying to find a job. I have been working on computers since I was 13. I started programing in basic that comes on graphing calculators and worked up to … | |
Re: I'm not sure about making it a void pointer but you should be able to make a weapons class that is the bass for all of your specific classes and then make a pointer of the base class and re assign it with your specialized class pointer. this would be … | |
Re: here is a good link for you. [url]http://www.daniweb.com/forums/announcement8-2.html[/url] | |
Re: could you post an example of the code you are having problems with? | |
Re: could you please post your code for your showArray() function. it looks like the problem will be in there. | |
Re: why are you randomly accessing the file? if you are going to use the whole file i believe it would be faster to read the whole file into an array and then access the array at random points. [code=c++] string array[256]; // just a guess use whatever number you need … | |
Re: the compiler i am using is MS C++ 2005. it runs better on my machine than 2008 does and i started with MS C++ 6.0 so it was a good and easy transition for me. the minimize code feature is really nice as well. | |
Re: to expand an array you could do this in your code [code=c++] int MAX_SIZE = 256; // just using 256 as an example int arraySize = MAX_SIZE; int * array= new int[MAX_SIZE]; // rest of your code // while in your loop of entering data if(arraySize % MAX_SIZE == 0) … | |
Hey all. I have written a quine and I was wondering if I have the jist of it right. I'm not sure if the code needs to be longer or this would be a suitable answer. Here is what I have. btw driver.cpp is the file name for my source … | |
Re: the 1120 error comes from the 2019 error. if you get a LNK2019 error you will always get a LNK1102 error | |
Re: you have no braces around your while function. should be [code=c++] while (i < NUM_EXAMS) { // <- dont forget these for multy line statements. input >> examScore[i]; sumOfTheScores += examScore[i]; i++ } // <- same here. [/code] | |
Re: well im not sure if you have to have a cout statement to have a cin statement but [icode] cin.getline(entryA, "\n"); [/icode] should work to get in a lot of input. | |
Re: also you do not have the definition of train(int) anywhere. your compiler doesn't know what to do because you didn't write the code for it. | |
![]() | Re: the easiest way to handle all different types of inputs is to receive them as strings and then go through them and figure out what the user entered. there are plenty of functions to help with this. the function isdigit() will test to see if the character is a number. … ![]() |
Re: the problem is that you are displaying the value of the ifstream reference. your while loop is good but you need to store the data into some other variable and then display it via cout. such as: [code=c++] //... while (!myfile.eof()) { myfile.getline(line, "\n"); cout << line << "\n"; } … | |
Re: just for giggles can you try [code=c++] while (index < NUM_PROG && cin >> prog[index]) { if(strcmp(prog[index], "-1") break; index++; } [/code] |
The End.