WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

need ur help regarding the above matter.

Please state the matter in the post. Don't use the title as part of your question. It's only meant to give us an idea about what we're about to read.

I've write a code for if statement but it didnt work as expected when I run the program.

I assume you mean the IF statments like:

if (sprintf(query2, 
            "select * from Register where MasterAccNo = 'NONE'") 
                    == 0)[b];[/b]

What the sprintf() statement does is load the first parameter (query2) with the rest of the parameters and returns the number of characters loaded. Therefore, each and every IF will fail.

But notice the character at the end of the IF (in red), that will end the IF. Therefore the code block is executed because it's not part of the IF at all.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hmmm, well, I came up with this int strLength = strlen(myArr)-1; and then in the loop for (int i = 0; i < strLength; i++) but I see where you're coming from :o

Thanks for the example, I'll see that I can find an equivalent to use in my program next week-end.

I would reverse the -1 and go with: int strLength = strlen(myArr); and for (int i = 0; i < strLength-1; i++) The reason is strLength actually represents the string length, which you can modify in the loop. And you can still use strLength elsewhere in your program if the need arises. By subtracting 1 first, it's really only useful for this particular part of the program.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Anatomy of an error message:

OK, check your code. Definition for enterScores is: void calculateAverage(int *, const int, double &); You call the function with calculateAverage(score, SIZE, averageScore); The error states

gradedani.cpp:19: error: cannot convert `double*' to `int*' for argument `1' to `void enterScores(int*, int)'

Argument 1 -- might mean score. What type of variable is score? What type of variable is the function expecting for parameter 1 (see definition)? Is there a conflict?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

For all those people who are still brooding over the question, here's the solution ...

Well, a solution... ;)

Any credits for it doesn't go to me though; but to my faculty who had asked the original question..

My ghod, what a mess! If this is the formatting you are being taught, run fast! No instructor should ever give unformatted code to anyone, especially his students!

Best use of pointer i would say..

What say u??

If you like gobbledy-gook. I will assume it works, but even with formatting there is no way I'm even going to try to follow this code. Too much obfuscation just to prove it can be done. This is a perfect example IMO of "just because it can be done doesn't mean it should be done."

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hey buddy,

If u really got ur review done from WaltP , can i have the code plz.

I am in a hurry u know !!

That's not how it's done here. If you want the code, you write it. We will help, but since we don't get your grade, we don't do your homework for you. We don't care how "in a hurry" you are -- cheating is cheating.

And please read this

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I would go about it differently

Loop thru words first to last-1, index is IDX1
{
    set FLAG to True
    Loop thru words IDX1 to last, index is IDX2
    {
        if word(IDX1) = word(IDX2) then
        {
            set FLAG to False
            break out of inner loop
        }
    }
    if FLAG is True, display the word, there is no duplicate
}

This way you will not print the duplicates if there is one further down the list -- you print the last occurence of each word. This will give you
two
one
three
four
five

Then you can work on your last step about sorting.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
#include <iostream>
#include <cstring>

int main()
{
	char wordArr[5][10];
	bool contr = false;
	size_t i, j;

	for(i = 0; i < 5; i++)
		std::cin >> wordArr[i];

	for(i = 0; i < 5; i++)
	{
		for(j = 0; j < i; j++)
		{
			contr = strcmp(wordArr[i], wordArr[j]);
			// If the above line sets contr to true or false...
			if (contr == true)    // what are these two lines for?
				contr = true;
		}
			if (contr == false)
				std::cout << wordArr[i] << '\n';
	}

	std::cin.ignore(2);
	
	return 0;
}

What is it you are trying to do?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Maybe even I should attempt and post the solution to Professor WaltP.

Yay atlast we get a qualified teacher who balks at void main ( ) :D

I don't like your attitude. Spit out that gum and sit in the corner... :twisted:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I've PM'ed it to WaltP for verification.

Yep, it'll work, for strings of a max length. You certainly have a different style than me :mrgreen:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Possibly, but it's not obvious. Somewhere you have to keep track of the the number of 'S's removed. The only thing I can think of is using recursion.

Search for an 'S' adding one to the pointer. When you find the 'S', call the function again using the current pointer location. Keep this up until you get to the trailing '\0' then return.

When you return,
copy *ptr+1 to *ptr, increment ptr, and stop when you copied the '\0'
Then return again.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Clarification:
1) You do not wish to use ANY local variables at all, so the only variable allowed in the function is the pointer to the string.
2) Using another function is not allowed.
3) You want to remove all 'S' characters, not just the first with this function.
4) Is this homework?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

<Dani takes off admin hat> But the original thread starter finished his project already, so there's no harm still discussing the topic and letting things into a deeper conversation about it. (Since the original fella was already helped, afterall) I've gotta convince you to stop thinking of the forums like a support ticket system and lighten up by letting conversations flow naturally. ;) :p :cool: <Dani puts admin hat back on>

Very good point. I had glossed over the fact that the project was finished... Sorry.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Let's make this more interesting...

Can anyone help me write the code for the same removeSfromString function without taking any local variables ....

i.e now the function is

void removeSfromString(char *str)
{
//no variable declaration here
}

Why? Is this likely to help the OP? If you want to offer a challenge, start a new thread, don't hijack someone else's thread

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

No one has even said ANYTHING about disabling the start menu...In the mean time I have found out how to not allow a user to click it, but they can still use the windows key (on the keyboard to access it...I have already been accused of trying to make viruses on other sites, but I am actually trying to lock my computer from unwanted access (little brothers, sisters) So if anyone could tell me how to do it that would be wonderful.

You could set up a user password and log off the user when you don't want them to use the computer. That's why the OS has been designed with users. ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I'm beginning now to wonder of a possible mistake, as I draw out the pointer stuff again.

Since the char array was "She'll be a massless princess", we will have to eliminate the first 'S'.

With this code, I have *str = *p, in the second iteration of the while loop, I replace the 'S' with 'h'. That is right, and as we go on, we get "he'll ..." However, aren't I supposed to allocate a space (empty char) if I have a 'S' or 's'? In this case, I'm not having that ..

No, p and str are using the exact same space. You are therefore overwriting the bad characters in the string with characters further on in the string.

Another way to write the exact same code without pointers is:

i = 0;
    j = 0;
    while (str[j] != '\0') // '\0' is the string-terminator character
    {
        str[i] = str[j];
        j++;
 
        if (str[i] != 's' && str[i] != 'S')
        {
            i++;
        }
   }
   str[i] = str[j];

So j is pointing to the next character to move (str in original code), i is pointing to the location where that character is to go (p in original code).

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Before you jump into windows programming with both feet, you should read this intoductory tutorial.

As well as this ;)
and this, the Keep It Organized section at least.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I'm hoping to use it to learn VB so that I can learn to use VBA in Excel and Word. Do you think I can do this with VB4?

I think you'd be better off just learning VBA if that's your main goal. Look for a VBA tutorial and start there.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

no its not sorry
4 is way too old (i think its 16 bit actually!!1) as 5 came out in 1996

No, Win95/VB4 was 32 bit.

Win3.1 was 16 bit and was essentially a DOS program rather than an O/S.

I doubt you can get an upgrade at this date but you can ask.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

That was a typo I think, she has already taken care of this in her last post.

Noooo, her last post has void deleteS (char ptr[]) and the instructions say
"Your function may not use any square brackets."

IMAO, this includes the definition, and even if it doesn't, the def can still be written without brackets. :)

Anyway, if you notice the times, I was responding while she was posting. It takes me more than 60 seconds to type up a response. ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

My task is this, and I'm having trouble finishing up the code:

Here is what I've managed so far:

void deleteS (char* ptr[])
{
   int*counter;
   for (counter = ptr; counter<ptr + strlen(ptr); counter++)
   {
       if (isupper(*ptr + counter)
          strcpy (" ", i);
       else if (*(ptr + counter) == 's')
               // delete the s, and move any blankspace back

I can't seem to come up with the remaining code. I hear that I can use a vector to delete elements (which is what I want to do), but I haven't learned that yet ..

How would I be able to finish up?

First thing, your function definition should be void deleteS (char* ptr) -- this passes in a pointer, you are passing in an array of pointers.

Next, set up another character pointer. You are not dealing with integers in this function. I'll call this pointer source

Set this new pointer equal to the parameter, like you did in the for statement. Now both pointers point to the same address.

Start a while loop that exits when when you reach the end of source ( *source == '\0' )

In the loop,
1) Copy the current character from source to the current character of ptr.
2) Increment source to point to the next character.
3) If the current character in ptr (the one just copied) is not 's' or 'S', increment ptr to point to the next character. This will overwrite any S that …

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Besides this, I am quite happy with our system. I just see the need for vast improvements. There are scores (see, 100's of 1000's, if not more) of American people who go daily without their prescribed medicine, (the very medicine that just might cure their ills) because they cannot afford to pay for it and they do not have insurance.

And there are those that could be helped by the correct medicine, but the insurance will only pay for cheaper, "kinda-like" medicine that is not adequate. The creater of XTree is one that I know of.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

warning C4996: 'strtok' was declared deprecated c:\program files\microsoft visual studio 8\vc\include\string.h(164) : see declaration of 'strtok' Message: 'This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'

Reinterpretation of this warning:
We at Microsoft know better than the standards committee that created the standards for C and C++. We therefore decree our way is better and don't give a flying %&#$ what the standard says. Switch to our proprietory functions so your programs aren't cross platform -- giving us domination over the computer industry. Mwah haaa haaaa!!!!! :twisted:
In other words, ignore them.


: error C2664: 'strlen' : cannot convert parameter 1 from 'char' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

What type of value is tokenPtr. What type of value does strlen() require?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

1st, IMAO you do not have to post the entire program, just the piece you are trying to fix, as you did.
2nd, as Ancient Dragon said, what's the name of the file? There is nothing in fname[]
3rd, please learn to format your code readably. You need consitant indentation. It's better to use SPACEs, not TABs. And it's good to use extra lines between sections, but not between everything:

int longest(void)
{
    char line[BUFSIZE] = {'\0'} ;
    int counter=0;
    int longest=0;
    char fname[128];
    FILE *file;
	
    file=fopen(fname,"r");

    while (fgets( line, BUFSIZE, file )!=0)
    {
        counter=strlen(line);
        if(counter>longest)
        {
            longest=counter;
        }
    }
    return longest; 
}

Another thing I noticed is a cute trick that you should not use:

nlines += c == '\n';/*Line counter*/

Instead use something easier to read:

if (c == '\n')  /*Line counter*/
{
    nlines++;
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The question I have is with your switch statement. What is the difference between all the cases? Could you describe the differences between each?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

As far as why not to use EOF is concerned, simple it reads the data from the file one too many times. For detailed explanation, see an excellent tuts by Mr.WaltP and if possible read all of them , they are good.

Actually, it's feof() that's the problem. EOF is a good thing to use, it just has to be used with a function that returns it... which fgets() does not...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I working on a program that summerizes text documents and I need a way to find the length of the longest and shortest lines in the file and display it in a log file. I've already done a character count and line count.

int main (void)
{
...
    while ((c = fgetc(file)) != EOF)
    {

Instead of fgetc() use fgets() to read an entire line. Then you can add a loop to continue doing the part you have already done, and you can check the length of the line for the min and max.

Or start a counter to count each character and when you read the '\n' test that counter against the current min & max. Then reset the counter to 0 and continue.

I recommend reading the first line and set min & max to the length of that line. That would be a good starting point.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Bump! Please help! My code is due very soon!

This is not a chat forum. Don't bump your posts. It's not necessary and we have lives outside the forums. Plus, your lack of planning is not an emergency for anyone but you ... sorry. We'll get to it when we get to it.

What it's supposed to do is take in a probe. If correct, it says how many probes it took to get the correct answer.

If wrong, it says how many letters were right from the secret word..

I tried compiling and stepping throguh, but it gives me wrong results. For example, I type in a probe, and it prompts me to type in a nother one without any output in between.

ex.
How many rounds do you want to play? 1
Round 1
Probe: aback
Probe: abet
3

Can you see what's wrong?

for (int a=1; a < rounds+1; a++)
    {
        cout << "Round " << a << endl;

        [b]// you play one round and throw away the result...[/b]
        playOneRound (myRand(10));

        [b]// ... then you play another round and output the result[/b]
        cout << playOneRound(myRand(10))  << endl;
        [b]// Therefore it looks like you input twice[/b]

    }

    return 0;
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I considered the idea of converting all input to int (from float or char) but I have had little sucess with my research with this so far, converting an input value to int from any possible other type (float, char, double, etc.)

Any advice, direction, or resources on this matter would be well appreciated. Thank-you in advance.

Are you sure you're ready for this? It's somewhat complicated ;)

First of all, your input must be in char* or string. Then you must check each character entered to see if it's the correct type of value -- like all digits for int. If there's a bad character, decide what you need to do -- convert what you can or call it an error and try again.

If all is well, convert the string and return the proper value.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So my questions would be:

1. is my general idea alright?

Yes. But you should pass in the hex array. C cannot return a character array. Also, format your code. Indentation is extremely important at all times. So is spacing between terms, like:

while (fscanf(a, "%d", &broj) != EOF)

Much easier to read.

char dek_hex(int m){    /* this is where my problems start. No matter
                           how I write the function, I keep getting all 
                           kinds of error messages */

Unless you post something you've tried, we have nothing to help with.

2. what should my function look like?

Basic idea in my previous post.

3. can it be done without a function?

Yes it can. Considerations:
function: Modularizes the program, easier to reuse the function in another program later. Somewhat easier to debug.
non-function: Not passing the hex array is a minor benefit.

like I mentioned in my previous post, printf() family of functions, which includes ssprintf(), will convert int to hex using "%X" .

Wouldn't this nullify the purpose of understanding how decimal to hex works? ;)

~s.o.s~ commented: Well said Mr. WaltP -- ~s.o.s~ +7
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

This will load the hex values from smallest to largest:

make a character array ([I]hexval[/I]) about 10 characters long
set whole array to spaces
set [I]hexval[9][/I] to '\0'
set [I]hexptr[/I] to 8 -- this will point into [I]hexval[/I] to load the hex chars.
Read a line into an integer ([I]intval[/I]) -- that's base 10.
Loop until that integer is 0:
    set [I]hexval[hexptr][/I] = [u]remainder[/u] of [I]intval[/I]/16 
    add 48 ('0') to [I]hexval[hexptr][/I]  -- this converts the integer value to a digit character
    if [I]hexval[hexptr][/I] > 57 ('9') add 7 -- value is now 'A' - 'F'
    decrement [I]hexptr[/I]  -- to load the next hex digit
    divide 16 from [I]intval[/I] -- to remove the hex val we just loaded
    End of loop
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

songnum is a variable, that's where my choice for a song is stored into it.

But I've solved all of that. My program works how I want it to, except for one thing.

When I add a song, I want it to add it to the right column, and do the time stuff, only if there is enough time left (remaining is bigger or equal to the time of the song). I have it so that it won't add it to the right column, and entering the number of the songs for the ones already on the right column does subtract the time, but the songs don't move back. I think know why they dont' move back. Because in a line of code I have it set so that it prints them on the right when the song's time is less than or equal to the remaining time.

But, one odd thing I've noticed, is that lets say I move the last three songs to the right, this will take up almost all the remaining time, only leaving 1:48. If I try to add another song bigger than that time, it won't add it, and it won't display it on the right, that's cool. However, when I try to remove songs from the right. It won't do it.

Like if I chose to remove one of them, it'll do the math right in the time displays, but the song will stay on the right. Why is that? If I enter …

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What is the songnum[] array for?
What is in it when this function is started?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Now, this part is my main problem. I'm trying to make it so that in my main function, when I select the songnumber of a certain song, it displays an "*" in front of the number. I don't understand how though.

If you think about it, when can if(select[songnum] == !select[songnum]) ever be true? Isn't this the same as if(val == !val) ?

Maybe something like if(songnum == i) is what you're looking for?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

:sad:

:mrgreen:
don't bump posts. When someone that can help comes along, they will. :evil:

I'm also having a problems with this section of my function. I am currently using a for loop, when it should be a while loop. The commented while loop there is what I'm trying to do, but it won't work, the program won't display anything.
...

for(index=1; index <9; index++)
     /*while(status !=EOF)*/

These two loops have nothing in common. Change the while loop to look like the for loop.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

One more suggestion -- format your code properly and wayward braces will no longer be a problem. Don't indent 3 tabs then next line 1 tab, then 2 tabs.

Your first brace should be far left and every line after indented 4 spaces. Each and every { indent 4 more spaces sterting with the next line. When you get to a } unindent 4 spaces, then add the } on a line by itself.

Then your code is easier to read:

void Look::printShipPos()
{
    if (checkFlag > 0) 
    {
        static int shipPos = 0;

        cout << shipPos << "_shipPos 1"<<endl;
        shipPos = shipPos + 228;
        cout << shipPos << "_shipPos added"<< endl;
    }


    if (shipPos == 228) 
    {
        std::cout << "French Polynesia [Out of Transmission Range]"<<endl;
        else if (shipPos == 456){
        std::cout << "Maui, Hawaii [Out of Transmission Range]"<< endl;
    }

    //---------------------counter for fly-over access
    checkFlag++;
    cout <<checkFlag<< endl;

    return;    
      
}
mattyd commented: TY :) +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hmm.. I think there is some kind of misunderstanding here Mr. WaltP. His requirement is that the palindrome should be case insensitive as well as "ignore whitespace characters".

No misunderstanding. My algorithm does exactly that.

While isalpha(str[ch1]) is false: 
    Increment ch1. 
    Return if ch1 > len.  
    -- pass back true or false, you get to figure out which.
...
If LowerCase(str[ch1]) == LowerCase(str[ch2])
    call palindrome() again with ch1+1 and ch2-1

Which says

While the current character is not a letter, 
    go to the next character
    verify we still have characters still in the string
...
If the two characters converted to lower case are identical
    call the function again with the next and prev characters

Trying to loop through the whole string to ignore whitespace characters is not feasible, would jsut result in reinventing the wheel when we have good inbuilt functions to handle such kind of situations.
strtok is just the kind of thing we need here IMHO. Comments are welcome.

It's perfectly feasible. That's what a palindrome parser does is test characters, not tokens. Please explain what is not feasible about my post.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

My first reaction is why bother with strtok()? This is a simple program of characters, not tokens.

Next, C has a function called tolower() and toupper() that will return the character passed in as an upper or lower case value. Good for comparing case insensitive values. It also doesn't affect non-alphabetic values.

Third, if all you are concerned with is letters, the function isalpha() is ready made for you. If letters and number, it's isalnum().

strlen()
will return the length of the string to it's end, not to where you want to stop, so taking the string length in the palindrome() function is not doing you any good.

And using gets() is a recipe for disaster. Best to convert gets(x) to fgets(): fgets(x, 50, stdin); My take on this is palindrome() should take 3 parameters
1) The string
2) Index to the first character in the string
3) Index to the last character in the string

Then palindrome(str, ch1, ch2) can process the string in this manner:

Set len to length of str (so you don't run off the end of the string)
While isalpha(str[ch1]) is false: 
    Increment ch1. 
    Return if ch1 > len.  
    -- pass back true or false, you get to figure out which.
While isalpha(str[ch2]) is false:
    Decrement ch2. 
    Return if ch2 < 0.  
    -- pass back true or false, you get to figure out which

// At this point you are looking at 2 alphabetic characters. …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Thanks I got it to work, but I'm not reading in the data from the file correctly. It looks like:

5   20
5   30
5   40

So I should be reading in only 3 lines for 3 calculations. The 5 is the temp, and the next nmber is the wind speed. Instead, it reads 6 numbers and makes 6 calculations :/

Well, we don't know what your code looks like that reads the file (I assume you've changed your code), there's not much we can suggest. Maybe you can post that section.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You can't program an exuation using math format. You have to use computer format. a(2+x) must be written as a[B]*[/B](2+x) . You must explicitly tell the program to multiply with *.

And be sure to put parentheses around every two terms. Don't assume a + b * 3 is the same as (a + b) * 3 -- it isn't.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i want the whole project fully finished do u ahve one where u could send me one

How much time will you give me to develop it? Are your specification complete enough for me to quickly code the project? How much is your grade worth to you? It's going to cost a bundle.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Have you been able to get the timer at least working? If so you're almost there. If not, simply make a quick program to understand how the timer works and use a text box to increment and display a count of each time the timer kicks off.

Then just use that timer to count the value down from your starting time. You can use the timer.enable property to start ad stop the timer for time-outs.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So, how do I get the length of a string in C++?

stringvariable.length()

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

its easy to use fputs for the char item[50] but still struggling with int cust_num (conversion) i'll appreciate any help !

Where did this conversion come in? I thought you were reading each line and replacing , with ;. There should be no conversions anywhere.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Actually Mr. WaltP did not direct his comment to you.

True. Thank you Mr. SOS for clearing that up in my absense. :)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Actually, you read from one file, then write to another file. You don't want to read and write to the same file. It gets too complicated.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hello...I need to write a program where i need to copy each word of a string into an array...
Eg(string s="hello how are you" arr[0]=hello,arr[1]=how....).
any help:?: ??

Thanks mate...but i need the solution in c++...is it posible??...sory for not specifying this at the start

In other words, "Thanks, but I can't turn that in as homework. Please write my homework for me properly."
:confused:

Grunt commented: Exactly :) [Grunt] +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Why use dynamic allocattion to define an 8x8 array? Just define board as int board[8][8] .

Create a function to display the board and just call it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How would i specify a Win32 project in Dev-C++? All that's listed is console, windows app, static library (.a), DLL and empty project.

Win32 == windows app

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Arrays must have a name.

Not in a prototype. Onlyt the type of the parameter is needed.

Curtis:
The file must be opened in the execution portion of the code since opening a file is an action. You have it in the declaration portion of the code. Put it in main() Use code tags. It's much faster and easier than coloring your code by hand and preserves the structure -- assuming you have structure. ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Is it better now. sorry I did it in a hurry.

#include <iostream>
using namespace std;
int main()
{
     int number=10;
     int x;
     int your_number;;
     char answer = 'y';
     cout<< "\n\nguess the number:\n";
     cin >> your_number;
 
     while (your_number != number || answer == 'y')
     {
       if(number == your_number)
       {
             cout<<"Congrat!\n\n";
             cout<<"\n Want to try again? ";
             cin>>answer;
             if(answer == 'y')
                 your_number = 0;
             else
             break;
       }
       else
       {
             cout<< "\n Guess number:\n";
             cin >> your_number;
       }
    }
 
return 0;
 
}
 
this is not part of your code.  ending code tag should go here 
SAMPLE OUTPUT:
NOTE:It was run on a linux machine.
 
smg@samoguz-desktop ~/Desktop
$ ./num
 
guess the number:
2
Guess number:
3
Guess number:
10
Congrat!
 
Want to try again? y
Guess number:
6
Guess number:
7
Guess number:
10
Congrat!
 
Want to try again? n
smg@samoguz-desktop ~/Desktop

#1) Does while (your_number != number || answer == 'y') do what you want? Make a truth table.

#2) If your while loop is already testing if the number is == or != just let the loop end. Then verify outside the loop it's because of the == and output the results. That will make your while loop simple and easier to debug. Just put in it the stuff that has to go in it. IOW separate the 'work' with the 'result display'