|
Use the loopback address.
127.0.0.1 or "localhost"
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
now i have only one problem with ip addresses. I have my internet domain name and my internet ip address, but none of them work from here. What am i supposed to use if i want to access the computer from outside my network?
-- Steve
|
|
|
|
|
I am making a project for school that is a game of tic-tac-toe. It is the console c++ not visual although I could do that but first I need one in console. See I need to make it work somehow and I was thinking of making an
if(user_inputbox1)<br />
...<br />
if(user_inputbox2)<br />
...
but for now I just have...
#include <iostream><br />
#include <cstdlib><br />
using namespace std;<br />
<br />
char matrix [3] [3];
<br />
char check();<br />
void init_matrix();<br />
void get_player_move();<br />
void get_computer_move();<br />
void disp_matrix();<br />
<br />
int main()<br />
{<br />
char done = ' ';<br />
<br />
init_matrix();<br />
<br />
do{<br />
disp_matrix();<br />
get_player_move();<br />
done = check();
if(done != ' ') break;
get_computer_move();<br />
done = check();
} while(done == ' ');<br />
<br />
if(done=='X') <br />
cout << "You won!\n";<br />
else<br />
cout << "I won!!!!\n";<br />
<br />
disp_matrix();
<br />
return 0;<br />
}<br />
<br />
void init_matrix()<br />
{<br />
int i, j;<br />
<br />
for(i=0; i<3; i++)<br />
for(j=0; j<3; j++) matrix[i][j] = ' ';<br />
}<br />
<br />
void get_player_move()<br />
{<br />
int x, y;<br />
<br />
cout << "Enter X,Y coordinates for your move: ";<br />
cin >> x;<br />
cin >> y;<br />
<br />
x--; y--;<br />
<br />
if(matrix[x][y]!= ' '){<br />
cout << "Invalid move, try again.\n";<br />
get_player_move();<br />
}<br />
else matrix[x][y] = 'X';<br />
}<br />
<br />
void get_computer_move()<br />
{<br />
int i, j;<br />
<br />
f: i = rand() % 3;<br />
j = rand() % 3;<br />
<br />
if(matrix[i][j] !=' ')<br />
goto f;<br />
<br />
if(i*j==9) {<br />
cout << "draw\n";<br />
system("pause");<br />
}<br />
else<br />
matrix[i][j] = 'O';<br />
<br />
<br />
<br />
}<br />
<br />
void disp_matrix()<br />
{<br />
int t;<br />
<br />
for(t=0; t<3; t++) {<br />
cout << matrix[t][0] << " | " << matrix[t][1] << " | " << matrix[t][2];<br />
if(t != 2) <br />
cout << "\n---|---|---\n";<br />
}<br />
cout << "\n";<br />
}<br />
<br />
char check()<br />
{<br />
int i;<br />
<br />
for(i=0; i<3; i++) <br />
if(matrix[i][0]==matrix[i][1] && matrix[i][0]==matrix[i][2]) <br />
return matrix[i][0];<br />
<br />
for(i=0; i<3; i++) <br />
if(matrix[0][i]==matrix[1][i] && matrix[0][i]==matrix[2][i]) <br />
return matrix[0][i];<br />
<br />
if(matrix[0][0]==matrix[1][1] && matrix[1][1]==matrix[2][2])<br />
return matrix[0][0];<br />
<br />
if(matrix[0][2]==matrix[1][1] && matrix[1][1]==matrix[2][0])<br />
return matrix[0][2];<br />
<br />
return ' ';<br />
}
Please make suggestions, comments, even brutal statements to make this a working, awesome app.. since the rand() is way off the computer move cause I just put it there to make it look how the comp would act.
MAINLY TRYING TO SOLVE THE GET_COMP METHOD TO MAKE THE COMP IF NOT UNDEFEATED THEN AT LEAST MAKE A DRAW...
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Well, to make the computer act like a person playing tick-tac-toe, have it select the center square first if possible. Second, to do vertical and horizontal rows, have the computer run a check of the vertical and horizontal rows, find one that is empty, and try to complete a row by using the same number for one of the array dimentions. I hope that helps.
-- Steve
|
|
|
|
|
Please could someone explain to me the difference between sock4 sock4a and socks5?
Best Wishes,
Marty
|
|
|
|
|
|
I have been wondering what is the best way to handle large scale projects and headers.
Currently for the VCF I have followed a 1 class = 1 header policy. For the Appkit I have ~ 233 .h files (acording to PLC).
Compiles, even with precompiled headers, take a bit. Is there a better way to organize the class declarations?
Is it smarter (even if it is not as easy to find classes) to *not* use the 1 class per .h rule, and instead combine many classes into one header?
Should common comment blocks (like CVS rev info, and copyright notices) fall before the include guards or within (or does it matter?)? For example:
(a)
#ifndef _FOO_H__
#define _FOO_H__
#endif //_FOO_H__
(b)
#ifndef _FOO_H__
#define _FOO_H__
#endif //_FOO_H__
Which is more efficient (a) or (b)?
I am using a fair amount of templates and some preprocessor stuff to add the extra RTTI support the framework uses. Does this make a big difference in compile times?
Thanks
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Jim Crafton wrote:
Which is more efficient (a) or (b)?
It probably won't make a noticable difference.
Jim Crafton wrote:
I am using a fair amount of templates and some preprocessor stuff to add the extra RTTI support the framework uses. Does this make a big difference in compile times?
Templatised code, especially when it changes frequently and is #included a lot can be a big killer. If you can, factor as much code from the template classes into base classes.
I've listed some other ideas. Top to bottom in priority of things to try.
Ensure that you aren't changing code in header files that are frequently included. This can be one of the biggest compile time killers. Also make sure you don't #include code you that you don't need. Use the pImpl idiom, use forward declarations, etc.
See items 26-30 from Herb Sutter's book 'Exceptional C++' for a really good explanation of this.
If you're using a microsoft compiler you might think about using #pragma once.
MSDN:
"Specifies that the file, in which the pragma resides, will be included (opened) only once by the compiler in a build."
From what I've read you may also juice a little more performance out by putting the include guard in the cpp file - I haven't tried this myself, but it might be worth a bit of research.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
If you're using a microsoft compiler you might think about using #pragma once.
Is using this pragma superior to include guards? Should it be done in addition to?
I'll definitely look into that
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Compiles, even with precompiled headers, take a bit.
Make sure that you effectively use precompiled headers: i.e. as much as possible files start with a maximum number of common lines of source code. For example, if one file includes:
#include <string>
#include <map>
and another one includes:
#include <map>
#include <string>
the precompiled headers are useless for those two files.
Serge
|
|
|
|
|
OK after ~14 hours of trying to understand why I am getting
HEAP: Free Heap block e0d998 modified at e0dc60 after it was freed
errors I am about ready to simply throttle someone and I think my wife is getting tired of me walking around cursing fluently under my breath.
Any suggestions for the best way to track them down? It only occurs when I run the programm in the debugger. If I just run it normally no error is flagged. I don't suppose I can just ignore it? (If i build in release mode I get no errors runnning the program).
Any thoughts on this would be most welcome!
The main thing I changed was moving the scope of a number of destructors in my classes from being public to protected.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Here are a few suggestions.
1. Run the app a few times to see if the memory address at which the error occurs remains same
2. If it reamins same problem is half solved. Set a data breakpoint that if the value at the particular memory location gets modifies you break into the debugger. This will help you see any illegal calls.
Somewhere in the world there is a machine language programmer waiting for that damned assembly language fad to pass. - Stan Shanon
|
|
|
|
|
OK Cool! I'll try that later on this evening - I'm gonna take a break from it for a bit and work on something else.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
hi , what is the fastest text drawing api?
im currently using "DrawText" because i want to use clipping and alignment.
when i profile my code , i can see that DrawText uses lots and lots of cpu
if i instead switch to "TextOut" , i get way way better performance , but i lose the alignment and clipping etc.
any other api that i might use that would be faster and still allow me to align/wordwrap/clip the text?
//Roger
|
|
|
|
|
Hi all
What happens when I use SendMessage for specific window from another thread?
I've debugged this situation and found out that I reach the window's procedure, wich executed by the main thread (and not by the thread that called SendMessage) but not via message loop... ???
|
|
|
|
|
|
Hi All,
I am writing an outlook style program and I want to be able to put CView derived classes in dll's to keep them seperate from the main application, problem is though that I also want to keep all data in the CDocument derived class which is in my EXE. Unfortunately it seems that the only things that can be accessed from the DLL's are the CDocument methods and not those in my own custom CDocument derived class. If I type cast ie. (MyDoc*)CDocument(), I get the unresolved symbol linker error, which leads me to believe I will have to put all of my data classes in each dll and compile them in there too. Is there anyway to avoid having to do this as it seems like more work than just keeping all of the CView derived classes in the main EXE, even though it seems messier.
Cheers,
Clint
|
|
|
|
|
Hi,
I'm using MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT to delete some temporary files if the user reboots the PC whilst using my program (XP/2000/NT - I'm using WinInit.INI for other systems). However, if the program closes normally, I need to cancel the MOVEFILE_DELAY_UNTIL_REBOOT for all the temporary files that it has been set for.
According to MSDN, MoveFileEx "stores the locations of the files to be renamed at restart in the following registry value:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations
This registry value is of type REG_MULTI_SZ. Each rename operation stores the following pair of NULL-terminated strings:
szDstFile\0\0
szSrcFile\0szDstFile\0\0"
I checked the registry using regedit, and found all the values there as specified, and discovered that, say if the file to be deleted is "c:\\test\test.exe", then it would be listed in the registry as:
\??\c:\\test\test.exe
Thus, to cancel all of registry entries, I tried this:
[code]
HKEY hKey;
char szRegKey[MAX_PATH];
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\PendingFileRenameOperations",
0,KEY_ALL_ACCESS,&hKey);
//this part should be looped for each file to be deleted:
strcpy(szRegKey,"\\??\\");
strcat(szRegKey,szFileToDelete);
RegDeleteValue(hKey,szRegKey);
RegCloseKey(hKey);
[/code]
However, this didn't work - all the entries in the registry were left just as they were.
Could anybody tell me where I am going wrong, and how to correct this so that I can delete all of the registry values that were added by MoveFileEx?
Any help much appreciated,
Many thanks,
KB
|
|
|
|
|
Can anybody help?
I discovered that my problem was that the strings I was trying to delete individually weren't the registry values, but "PendingFileRenameOperations" was the value - which I was treating as a key.
Thus, I can use this code successfully to remove "PendingFileRenameOperations", the value created by MoveFileEx:
[code]
HKEY hKey;
char szRegKey[MAX_PATH];
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\Session Manager",
0,KEY_ALL_ACCESS,&hKey);
RegDeleteValue(hKey,"PendingFileRenameOperations");
RegCloseKey(hKey);
[/code]
The problem with this, of course, is that if any other programs have used MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT, then my program will delete all this info too, which is undesirable.
Does anyone know how I can delete *only* the strings that my program has added to the PendingFileRenameOperations value?
Or, is there a function that will allow me to back up the original "PendingFileRenameOperations" value when my program starts (eg. by copying it with a different name), then add the values I need, then if my program ends normally I can replace the updated "PendingFileRenameOperations" with the backup (so that in effect the values I have added are deleted)?
Many thanks for any help,
KB
|
|
|
|
|
Ah, figured it out. I just use RegQueryValueEx to get the value of PendingFileRenameOperations when the program starts. If it returns ERROR_SUCCESS, I just replace the changed value with the saved value when the program ends using RegSetValueEx, otherwise I delete PendingFileRenameOperations using RegDeleteValue().
Thanks anyway,
KB
|
|
|
|
|
hi...
Usually the list ctrl's entire client rect is white by default.
If i want to have a different bk color when it gets the focus and also when it looses the focus.
Any help is appreciated.
Thanx
saleem
|
|
|
|
|
One solution is to derive a class from CListCtrl and do custom drawing.
Kuphryn
|
|
|
|
|
|
Michael Dunn wrote:
Ericahist updated Aug 30!
Does she know she has a stalker by the way?
--
Frivolous Theorem of Arithmetic: Almost all natural numbers are very, very, very large.
|
|
|
|
|
just call CListCtrl::Setbkcolor(RGB(255, 255, 255)); //the color you want
Sonork 100.41263:Anthony_Yio
|
|
|
|