NathanOliver 429 Veteran Poster Featured Poster

Sorry about that nitin1. Not sure what I was thinking.

NathanOliver 429 Veteran Poster Featured Poster

You start with a = 3. So line 2 will print a which is 3 then a gets incremented to 4. then it prints the space. Then a gets incremented to 5 then a which is 5 gets printed agian.

This has to do with how the post and pre increment operators work. a++ means give me a then add 1 to it. ++a means add 1 to a then give me what a now holds.

NathanOliver 429 Veteran Poster Featured Poster

What is the code you are using to display the diagonals? You basiclly need to invert the display logic to have it display the non diagonals. As an FYI this is how I would display the diagonals

// this assumes the array is sqaure and size is the size of the array
// the array is named numbers
int step = 1;

for (int i = 0; i < size; i++, step++)
{
    for (int j = 0; j < size; j++)
    {
        if(j + 1 == step || step + j == size)
            cout << numbers[i][j] << " ";
    }
}
NathanOliver 429 Veteran Poster Featured Poster

@ nitin1

std is a namespace that all of the standard c++ functions and classes are in. A namespace is just another level of orginizing your code. You can equate it to the file cabinet metaphor. The function is a piece of paper. The file the function is in is a folder. The namespace is the drawer that the folder is in. Your project is the file cabinet that contains it all.

nitin1 commented: awesome metaphor!! +3
NathanOliver 429 Veteran Poster Featured Poster

From what I have experianced reading or writing to the file is slower than reading or writing to an array. The OS might load the file into RAM but I dont think streams in c++ don't.

NathanOliver 429 Veteran Poster Featured Poster

The way I would do this is to read in all of the questions into an array. After that then shuffle the array around. Here is a little example

std::string questions[15];
// load the questions into questions[]

srand(time(NULL));  // this seeds rand
int randIndex;

for (int i = 0; i < 15; i++)
{
    randIndex = rand() % 15;  // gets a random number from 0 to 14
    std::swap(question[i], question[randIndex]);
}
NathanOliver 429 Veteran Poster Featured Poster

Don't forget that you will need to add the counter increment to the copy constructor and the assignment operator. You probobly want to have that as a seperate counter since those objects will be implicitly created.

NathanOliver 429 Veteran Poster Featured Poster

Well one way to fix that is to see what is bigger and if the number that is being subtracted is larger than the number it is being subtracted from switch them around. Then do your normal subtraction and add a "-" to the result.

10 - 100 = -90

Swap 10 and 100 and add the negitive

100 - 10 = 90 * -1 = -90

NathanOliver 429 Veteran Poster Featured Poster

First off your coveredarray should be of type char not int. Secondly what I would do is load guessarray with the numbers 1-9 in order. Then I would go through the array and swap the element of the current index with one that is randomly generated. To do that take a look at this:

int randI, randJ, temp;
// seed random generator
int number[3][3];  // make this hold 1-9

for (int i = 0; i < 3; i++)
{
    for (int j = 0; j < 3; j++)
    {
        randI = rand() % 3;  // get random index
        randJ = rand() % 3;  // get random index
        temp = number[i][j];  // store number from current pos.
        number[i][j] = number[randI][randJ];  assign current pos with random
        number[randI][randJ] = temp;  // assign random pos with current
    }
}

To ask the user what spot they want you can ask them for the row and coulmn and use that.

NathanOliver 429 Veteran Poster Featured Poster

Is it just me or did the whole UI change in the last hour or so?

NathanOliver 429 Veteran Poster Featured Poster

Well in the warning you got it says the file name can't be "aux" and you are using that. Try chnaging the name of your file to something else.

NathanOliver 429 Veteran Poster Featured Poster

Do you know the STL? If not check this out.

NathanOliver 429 Veteran Poster Featured Poster

I know microsoft uses -1 as true if you are using access so it makes sense that they are doing that with there compiler. AFIK any value other than 0 is considered true and I havent seen a case where that doesnt work.

NathanOliver 429 Veteran Poster Featured Poster

The code in your first piece of code should not compile. More than likely there is some sort of compiler extension taking care of it for you. What compiler are you using? Static arrays can only be initialized with a const size argument.

NathanOliver 429 Veteran Poster Featured Poster

a const function can be called by a non const function. a const function can only call other const functions. the same thing applies to objects as well.

NathanOliver 429 Veteran Poster Featured Poster

Just as an FYI. If you call erase on a vector and you are using iterators any iterator that is after the begining will be invalidated.

NathanOliver 429 Veteran Poster Featured Poster

I would suggest using something other than graphics.h. it is not supported by any modern compilers and it will only work in a dos enviroment.

NathanOliver 429 Veteran Poster Featured Poster

what compiler are you using? if you are using msvc++ you have to pick a win32 console application.

NathanOliver 429 Veteran Poster Featured Poster

You are trying to initialize a 2d array when you onlty declared a 1d array. You can change it to

char arrayOnes[][10] = {"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}

If you can use strings I would suggest doing this

std::string arrayOnes[10] = {"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}
NathanOliver 429 Veteran Poster Featured Poster

can you post the code?

NathanOliver 429 Veteran Poster Featured Poster

do you know the % operator? do you know how to use an loop? do you know how to use an array? those are really all you need to figure this out.

NathanOliver 429 Veteran Poster Featured Poster

you need a closing brace on line 704. you also would benifit greatly properly indenting your code.

NathanOliver 429 Veteran Poster Featured Poster

There isnt a way to add commas to the output natively but you can wrtie a function to do it for you.

NathanOliver 429 Veteran Poster Featured Poster

I am amazed that people don’t even try to Google for an answer. Most of the time the first page has the answer and so much more.

NathanOliver 429 Veteran Poster Featured Poster

Yes a char* is a pointer to a char that can be modified. a const char* is a char pointer that cant be modified.

NathanOliver 429 Veteran Poster Featured Poster

You can use the same method. Instead of using cin you would use the file stream you create.

ifstream fin("testfile.txt");  //create ifstream object to read the file
string line;
vector<string> fileContents;

while(getline(fin, line))
    fileContents.push_back(line);

As you can see from the above example fin is the file stream to read from the file. fileContents is a vector that will store each line of the file. The while loop uses the return value from getline to know if a line was read from the file. If the getline operation fails the loop stops and nothing more is read from the file. Inside the while loop the contents of the variable line are then added to the back of the vector.

If you want a good reference site I would suggest visiting cplusplus.com. They have a lot of tutorials and references. And of course if you have problems come back here and someone should be able to help.

furalise commented: Excellent answer. Thanks for the help. +0
NathanOliver 429 Veteran Poster Featured Poster

What do you mean by getting the sentence from somewhere else? Do you mean like getting it from a file or passing the variable to the program using the command line? If you put the sentence in a variable you can use it in your progrma anywhere you want to as long as that variable is visable to the code block you are in.

NathanOliver 429 Veteran Poster Featured Poster

Well if you want to store the sentance in a variable use a string not a stringstream. Your code would look like this

string line;
getline(cin, line); // gets the sentence from the command line and place it in line
cout << "You Entered: " << line << endl;
NathanOliver 429 Veteran Poster Featured Poster

We don't do homework. What code do you have so far?

NathanOliver 429 Veteran Poster Featured Poster

The first thing I would do is name your variables something descriptive. I'm not sure of the rest of the people on this site but if your code isnt somewhat easy to read I'm not going to make the effort.

NathanOliver 429 Veteran Poster Featured Poster

@ sanyam.mishra char* argv[FILENAME_MAX] is an array of pointers so it is a 2d array.

@ DarrelMan have you walked through the code with the debugger to see what is inside argv[0]? If you dont know how to step through the code with the debuger you could just output the contents of argv[0] to the console using a cout statement. That should at leat tell you what you have. it could be there is a slight mismatch.

NathanOliver 429 Veteran Poster Featured Poster

Can you narrow down where the problem is. I'm not going to read ~1000 lines of code to find the answer.

NathanOliver 429 Veteran Poster Featured Poster

Sure you can do this with c++. You will need to know how to use file streams and strings.

NathanOliver 429 Veteran Poster Featured Poster

add this after line 14 to see if your file is being opened.

if(!myfile)
    std::cout << "Unable to open file" << std::endl;
NathanOliver 429 Veteran Poster Featured Poster

Not to pick nit but shouldn't line 35 be delete [] p;, since the first level of p is in itself an array?

deceptikon commented: Thanks! +12
NathanOliver 429 Veteran Poster Featured Poster

Passing by reference or value should be pretty much the same for POD types. In this case your struct only contains POD types so passing the struct by value or passing all of the variables by reference should be the same. If you want to you can pass your struct by reference. It might give you a little bit of a boost.

void Returns(returns & returner)
{
}
NathanOliver 429 Veteran Poster Featured Poster

@AD Wont the compiler see that the value of the expression never changes and optimize it away?

NathanOliver 429 Veteran Poster Featured Poster

This is a shell for what I would do.

std::string filename;
// get the filename and put it in the string

std::ifstream fin(filename.c_str());
std::vector<std::string> file;
std::string line;

// read in file
while (std::getline(fin, line))
    file.push_back(line)

fin.close();
for(int i = 0; i < file.size(); i++)
{
    // code to go through the string and add 'b' before 'B' here
    // using the string methods find() and insert() will help here
}

// write the vector to the file replacing the old version of the file
std::ofstream fout(filename.c_str())
for (int i = 0; i < file.size(); i++)
    fout << file[i];

fout.close();
NathanOliver 429 Veteran Poster Featured Poster

If I was doing this I would read each line of the file into a string array. After that I would go through each string in the array and insert a b in front of every B. Then I would just overwrite the contents of the file with the modified array.

NathanOliver 429 Veteran Poster Featured Poster

You might be able to narrow down where in the process memory the address is likely to be and just scan that area.

NathanOliver 429 Veteran Poster Featured Poster

what is in ar[] when you pass it to your constructor? Can you post the code that is not working? You need to be a little more detialed with your question/problem when posting. Having to play 20 questions is not something I want to do. You need to have a clear explanation as to what is not working and all relevent code. Don't post all of the code just what we need to see how it works.

NathanOliver 429 Veteran Poster Featured Poster

Line 5 should be sales[i] = ar[i]. All subsequent uses of ar[i] should be replaced with sales[i].

NathanOliver 429 Veteran Poster Featured Poster

It is not the same thing

Sales::Sales()
{
    double sales[] = {0.0, 0.0, 0.0, 0.0};
}

The above code creates an double array called sales in the constructor which hides the sales array that is a member of the class. Once the constructor is done this local array that has all zeros is deleted.

Sales::Sales()
{
    for(int i =0 ; i < QUARTERS; i++)
    {
        sales[i]=0.0;
    }
}

This code uses a loop and sets each element of the sales array that is a member of Sales to 0.

NathanOliver 429 Veteran Poster Featured Poster

Are you sure it is opening the file? Put a cout statement between lines 112 and 113 and see if it prints the stament. This will let you now if the file was opened succesfully. It should work if the file is being opened. What does the file look like?

NathanOliver 429 Veteran Poster Featured Poster

where are you getting a value for hwndDC? does hwndDC hold a handle to the window of the game you are trying to hack?

NathanOliver 429 Veteran Poster Featured Poster

What is openFileIn(file, "Register and Login Details.txt") returning? Are you actually getting into the loop? Where is the file located that you are trying to read? If you are not fully qualifying your name then it needs to either be where your source files are or in the same location as the .exe file.

NathanOliver 429 Veteran Poster Featured Poster

So what is the problem exactly?

NathanOliver 429 Veteran Poster Featured Poster
#include <iostream>

int main()
{
    std::cout << "Hello World!" << std::endl;
    std::cin.get();
    return 0;
}
NathanOliver 429 Veteran Poster Featured Poster

This is a C++ program that reads as input a text file.

Where? I didnt see one.

NathanOliver 429 Veteran Poster Featured Poster

give this article a look.