line 15 should be
int TNT_DrawSprite(tnt_Player & PlayerRef);
line 15 should be
int TNT_DrawSprite(tnt_Player & PlayerRef);
using getline should work for you. I would suggest this
// inside function
string serial;
cout << "Please enter a serial number. Enter to quit: ";
getline(cin, serial);
while(!serial.empty())
{
serialNumbers.insert(serial);
cout << "Please enter a serial number. Enter to quit: ";
getline(cin, serial);
}
It is to be noted there is no error checking here so the user could enter a letter and it would be excepted.
Did that fix it? no need to be sorry code tags just make it easier to read. Also formating is also important a good guide is here http://www.gidnetwork.com/b-38.html
could you please re post your code wrapped in code tags? there is a space in the first variable name here
if (sc 1 <= sc2 && sc1 <=sc3 // space in the first sc1
&&sc1 <= sc4 && sc1 <=sc5)
There might be all I'm seeing is "c". ;)
Maybe you could create a program that will compile the cpp files and save the assembly code into a file and then see if the assembly code is the same. Otherwise I guess you would have to create a parser and store the code as tokens and then match the tokes.
Another apporach would be to use getline. Something like this should work
string filename;
cout << "Enter the filename: ";
getline(cin, filename);
ifstream OpenFile(filename.c_str());
//...
You will need to add #include<string>
to your code for this to work. Also you are using the headers you have are depreacted. You have
#include <iostream.h>
#include <fstream.h>
// change that to this
#include <iostream>
#include <fstream>
BTW what compiler are you using?
As your example shows you have a number followed by a bunch of data. You could use a map the is defined as map<int, vector<something> >
. this would allow the number in each line to be the key and then the vector would hold all of the other data in the line associated with that number.
you have a semicolon after your function name
void average (int sc1, int sc2, int sc3,int sc4,int sc5); <--- get rid of this
{
// ...
}
void findLowest (int sc1, int sc2, int sc3, int sc4, int sc5); <--- get rid of this
{
// ...
}
why do you have median in your main paramaters? medain should be defined in main
int main()
{
float meadian = 0;
// rest of your code
}
you are not actualy defining string B. to define it to be be you could do this
string B = "B";
I'm not seeing median declared in your main function at all. also the median is average value of all the values in the array. to calculate that you need to loop through the array and add all the values together. After that you then dived that sum by the number of elements to get the average. Also you need t pass the value median into your function by either a pointer or a reference so that what you do to it inside the function is reflected in main. Passing by value as you are doing now will not change the value of median in main().
there is a problem with your search user function. you never initialize i. your call to cin replaces the account number with whatever the user enters. to search for a record you need a for loop to check the number entered by the user against the numbers stored in the array. not sure if this is the function your talking about though.
have you though about using the STL instead of arrays of pointers. I would suggest a list if you are going to be adding or deleting elements anywhere in the list or a vector if you are only going to be adding or removing elements from the end. from the look of your code i think a list would work well for you.
You have i and j initialized to size so you are actually pointing to one passed the end of the vector. Replace
int i=(int)ask.size();
int j=(int)buy.size();
with
int i=(int)ask.size() - 1;
int j=(int)buy.size() - 1;
Also with this line
matchedAsk.insert(matchedAsk.end(),ask.end(), ask.end()+1);
I belive you are using the iterators to insert the element of the vector into another container. But end() poins to one past the end of the vector so if you want to get the last element in the vector you would have to use
matchedAsk.insert(matchedAsk.end() - 1,ask.end() - 1, ask.end());
Thanks Dani
Sounds like you might need to re flash your bios.
Looks like it is fixed now.
Well I'm glad it isn't just me. Thought I was going more insane than I already am.
There is also a problem with the page buttons. Trying to hit next or 2,3,4... goes to the associated page in the administrator forum. At least for me that is.
Same thing in troubleshooting dead machines
well i looked on my MSDN and from what i found there is a System.Drawing namespace. Could this be what it should be?
using namespace System.Drawing;
could you please post the point class code.
is Color part of using namespace System::Drawing;
? if not you need to include it in your point class. this is all i can get from this.
the function is constantly reducing the number untill it is less than 10.
lets say the number is 100. the function would print 0 for the first time. then you check to see if it is greater than 10. since 100 is greater than 10 we will call the print function but this time we will dived 100 by 10 and pass that into the function.
so now we have 10. we do the same thing and again it displays 0. 10 is not less than 10 so we dived 10 by 10 and call the function again.
now we have 1. 1 % 10 is 1 so it displays 1. now 1 is less than 10 so we print out a blank line and exit the function via the return statement. since this is a void function we don't need to return anything.
So this function prints out a number backwards using recursion. if you still are unclear about any of this let me know. also if you are using a newer compiler i would suggest setting a break point in the function and stepping through it with the debugger to watch it work.
[EDIT]
Xorlium beat me to it. ;)
Could you post the full error message?
as caut_baia stated you are returning a pointer but your function is defined to return just an object
change this
return rslt;
to this
return *rslt;
on line 159 you have score += 100;
and you haven't initialized it yet. then only time before line 159 that score is used is when it was declared as int score;
.did you delete a score = 0;
when you added the enemy part?
could you please explain exactly what you mean.
why is that? do you want to write matrix a = matrix b and then use another function or line of code to actual set the data in a to the data in b?
where is the data vector in you matrix class definition. I'm seeing you using it in your constructors but its never defined. also in you operator= function you aren't copy the data from the other matrix. all you are doing is changing the size of the vector.
the problem is you are using random numbers so the situation changes every time. also you are not using srand before the first call to rand so you are using the same set of random numbers every time.
could you please post your whole code where you set up your matrix?
well big O notation is like a worst case scenario of what the function will do an upper bounds. take 1,2,3,4,5,6,7,8,9 as an example. if you passed this into your sort function it would run the minimum number of times. so depending of the values of the array the sorts will run differently
How big is the vector inside the vector? The main vector is of size 3 so the subscript [2] should be fine but I don't see anything for the size of each vector in distance. what would happen if you accesses distance[1][2]. Does that throw an exception?
well it looks like you have a counter in each one. are they not counting correctly?
Does this actually compile? In your encryption function you are overwritting the bounds of the encryptedChar string. I would suggest using the append function to add charactures to the string. Or make encryptedChar the same size as encrypt_code and then assign it with your index.
Delcare your function before main and try to compile agian
change your do...while loops to just a while loop.
do
{
cout<<endl<<"Invalid. User Id must be at least 6 digits. Retry:";
cin.getline(userId, 20);
length = (long)strlen(userId);
}while(user_ID_length(userId, length)==false);
// to
while(user_ID_length(userId, length)==false)
{
cout<<endl<<"Invalid. User Id must be at least 6 digits. Retry:";
cin.getline(userId, 20);
length = (long)strlen(userId);
}
first for your strncmp you need to make pass the string email_address as a char*. to do this you need to use the c_str() method
strncpy(userId, email_address.c_str(), 9);
second isalpha actually takes an int so you can only use a single character not a whole string so you would need to write a for loop to go through each element of the array and call isalpha on that.
third you are using do..while loops. i would use while loops instead because as it stands you will run the loop at lease once even if your input is correct. also i believe you are calling functions in you while part of the loop but there is no (). if
}while(user_ID_length==false);
// did you mean?
}while(user_ID_length(userId, length) == false);
if you have any more problems please post them and i would be happy to help
the getline function uses a delimiter in when determining when to end the input. the default is '\n' but you can change it to whatever you want.
string getLine(string line)
{
getline(cin, line, '-');
return line;
}
well you can use getline with '-' as the delimiter so you don't need to check for the negative. also your function is returning void. are you sure you want to do that? I believe you would want to return the string to the function that called this function.
your check if either player has more than the points needed to win is not inside your do while loop. it is only checked before you enter the loop and then you go on forever.
so if you have the string "hello" and the string "loot" it would become "helloot" since the ending "lo" of hello and the beginning "lo" of loot are the same? and "helloeDelhi" hase no over lap so it isnt truncated correct?
im not seeing a #include <iostream>
anywhere.
You need to use srand() to seed rand before you use it. For a game like yours i would use srand((unsigned)time(0));
. You will need to use #include <ctime>
in your code to do this.
you would need to reset i to zero and then assign the return to s2 and increment i after each time.
you are not assigning the return from s.pop() to anything. also please use code tags
because all an array is is a continuing block of data in memory. c/c++ doesn't care if its one or a million. the function only needs to know where the data starts at. you know its an array and can program accordingly for it.
the function collision you have for your coord class right now is collision(coord[]). im saying just to make it collision(coord). then in the function re write your if statement to look like
if(this->xx == asteroid.getxx() && this->yy == asteroid.getyy())