|
Possibly, but your question has nothing to do with C++. Please try one of the Web Development forums.
|
|
|
|
|
Ohh ok thanks 
|
|
|
|
|
Member 11675472 wrote: code my website so when new customers sign up, they are automatically sign up for the hundrends of websites listed on my website/platform ?
Hundreds?
Just because you can doesn't mean you should.
|
|
|
|
|
Hii
I am a beginner of C++ programming environment.
My question:
Suppose there is a array..and the contents of the array="ironman"
Now, i need to insert some additional character to this string like "i*r%o#n@m^a!n"
Also i need to reversely generate the original contents. That means from "i*r%o#n@m^a!n" to "ironman"..
Also i have one constraint, i cannot use much of library function..i can use loop only.
Thanks in Advance !!
|
|
|
|
|
What have you tried?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Think about how you address elements of the array; that will help you to change particular letters. Similarly that will give you a clue how to reverse it.
|
|
|
|
|
Well, it doesn't look a daunting task, however you have to allocate a new array having the double size of the original one.
Then you could copy the original items o[i] into new ones n[2*i] , finally add the 'additional characters at odd indices.
The inverse operation, is, well, inverse, namely n[2*i] -> o[i] .
|
|
|
|
|
Hi,
I want to list out the captions of all open windows on desktop (the items which all are shown on task bar). I tried using 'EnumDesktopWindows' function but it provides too many unnecessary window handles.
Can we filter the actual windows from the list provided by above API?
Regards,
Krishnakumar T. G.
|
|
|
|
|
Krishnakumartg wrote:
Can we filter the actual windows from the list provided by above API? For each window handle, check to see if it has a captain, and if it is visible. That should narrow it down.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Thanks. It worked with some hard coded exclusions like "Start", "Program manager" windows.
|
|
|
|
|
Hi,
I want to get the list of Browser Add Ons using C++. Is there any WMI query using which this can be solved or any other method to achieve the same.
Browser Can be any browser i:e: Internet Explorer, Chrome etc...
Any help will be appreciated.
Regards,
|
|
|
|
|
This information is internal to each browser, so you need to check their developer websites.
|
|
|
|
|
#include <time.h>
#include <iostream>
#include <string>
#include <iomanip>
/*http://rosettacode.org/wiki/2048*/
typedef unsigned int uint;
using namespace std;
enum movDir { UP, DOWN, LEFT, RIGHT };
class tile
{
public:
tile() : val( 0 ), blocked( false ) {}
uint val;
bool blocked;
};
class g2048
{
public:
g2048() : done( false ), win( false ), moved( true ), score( 0 ) {}
void loop()
{
addTile();
while( true )
{
if( moved ) addTile();
drawBoard();
if( done ) break;
waitKey();
}
string s = "Game Over!";
if( win ) s = "You've made it!";
cout << s << endl << endl;
}
private:
void drawBoard()
{
system( "cls" );
cout << "SCORE: " << score << endl << endl;
for( int y = 0; y < 4; y++ )
{
cout << "+------+------+------+------+" << endl << "| ";
for( int x = 0; x < 4; x++ )
{
if( !board[x][y].val ) cout << setw( 4 ) << " ";
else cout << setw( 4 ) << board[x][y].val;
cout << " | ";
}
cout << endl;
}
cout << "+------+------+------+------+" << endl << endl;
}
void waitKey()
{
moved = false; char c;
cout << "(W)Up (S)Down (A)Left (D)Right "; cin >> c; c &= 0x5F;
switch( c )
{
case 'W': move( UP );break;
case 'A': move( LEFT ); break;
case 'S': move( DOWN ); break;
case 'D': move( RIGHT );
}
for( int y = 0; y < 4; y++ )
for( int x = 0; x < 4; x++ )
board[x][y].blocked = false;
}
void addTile()
{
for( int y = 0; y < 4; y++ )
for( int x = 0; x < 4; x++ )
if( !board[x][y].val )
{
uint a, b;
do
{ a = rand() % 4; b = rand() % 4; }
while( board[a][b].val );
int s = rand() % 100;
if( s > 89 ) board[a][b].val = 4;
else board[a][b].val = 2;
if( canMove() ) return;
}
done = true;
}
bool canMove()
{
for( int y = 0; y < 4; y++ )
for( int x = 0; x < 4; x++ )
if( !board[x][y].val ) return true;
for( int y = 0; y < 4; y++ )
for( int x = 0; x < 4; x++ )
{
if( testAdd( x + 1, y, board[x][y].val ) ) return true;
if( testAdd( x - 1, y, board[x][y].val ) ) return true;
if( testAdd( x, y + 1, board[x][y].val ) ) return true;
if( testAdd( x, y - 1, board[x][y].val ) ) return true;
}
return false;
}
bool testAdd( int x, int y, uint v )
{
if( x < 0 || x > 3 || y < 0 || y > 3 ) return false;
return board[x][y].val == v;
}
void moveVert( int x, int y, int d )
{
if( board[x][y + d].val && board[x][y + d].val == board[x][y].val && !board[x][y].blocked && !board[x][y + d].blocked )
{
board[x][y].val = 0;
board[x][y + d].val *= 2;
score += board[x][y + d].val;
board[x][y + d].blocked = true;
moved = true;
}
else if( !board[x][y + d].val && board[x][y].val )
{
board[x][y + d].val = board[x][y].val;
board[x][y].val = 0;
moved = true;
}
if( d > 0 ) { if( y + d < 3 ) moveVert( x, y + d, 1 ); }
else { if( y + d > 0 ) moveVert( x, y + d, -1 ); }
}
void moveHori( int x, int y, int d )
{
if( board[x + d][y].val && board[x + d][y].val == board[x][y].val && !board[x][y].blocked && !board[x + d][y].blocked )
{
board[x][y].val = 0;
board[x + d][y].val *= 2;
score += board[x + d][y].val;
board[x + d][y].blocked = true;
moved = true;
}
else if( !board[x + d][y].val && board[x][y].val )
{
board[x + d][y].val = board[x][y].val;
board[x][y].val = 0;
moved = true;
}
if( d > 0 ) { if( x + d < 3 ) moveHori( x + d, y, 1 ); }
else { if( x + d > 0 ) moveHori( x + d, y, -1 ); }
}
void move( movDir d )
{
switch( d )
{
case UP:
for( int x = 0; x < 4; x++ )
{
int y = 1;
while( y < 4 )
{ if( board[x][y].val ) moveVert( x, y, -1 ); y++;}
}
break;
case DOWN:
for( int x = 0; x < 4; x++ )
{
int y = 2;
while( y >= 0 )
{ if( board[x][y].val ) moveVert( x, y, 1 ); y--;}
}
break;
case LEFT:
for( int y = 0; y < 4; y++ )
{
int x = 1;
while( x < 4 )
{ if( board[x][y].val ) moveHori( x, y, -1 ); x++;}
}
break;
case RIGHT:
for( int y = 0; y < 4; y++ )
{
int x = 2;
while( x >= 0 )
{ if( board[x][y].val ) moveHori( x, y, 1 ); x--;}
}
}
}
tile board[4][4];
bool win, done, moved;
uint score;
};
int main( int argc, char* argv[] )
{
srand( static_cast<uint>( time( NULL ) ) );
g2048 g; g.loop();
return system( "pause" );
}
|
|
|
|
|
Sorry, this site does not provide a code writing, or rewriting, service.
|
|
|
|
|
Points #2 and #4 of this seem to apply to you.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Why not save yourself even more effort and just get your degree in the post? You will be as useless to the IT industry in either case.
|
|
|
|
|
Hi
all of the sudden out of the clear blue sky in any of my CWinApp methods constructor Initinstance, any declaration of CEvent is flaged as an error say the complier doesn't recognize that type whether I declare it on the Stack CEvent myevent or on the heap CEvent *evenptr = new CEvent, If I declare globally or some other class CMainFrame for instance
its ok
|
|
|
|
|
|
I have stdafx.h if that's what you're referring too
I going to create a MFC MainFrame type project and cut and paste the code to it
thanks
|
|
|
|
|
Er, no, that is a project file that should contain the #include statements for all the required headers. Have you checked the link I gave you for the name of the necessary header, and also checked that you have it included in your stdafx.h?
|
|
|
|
|
Thing is it compiled cleanly the day before I made some unrelated coding changes
And I started getting those
Errors
I started the project along time ago when I didn't know anything about MFC it was kind of sloppy this was a good opportunity for me to clean it up I created a project with the same name on a different drive and it looks good those compile errors went away
As soon as I finish i going to copy it back to the original spot overlay the code with this
Thanks
|
|
|
|
|
Hi,
I have a derived CAsyncSocket class which is a protected member of a Derived CWinThread class
There are 4 of the derived CWinThread Classes each with their own derived CAsynSocket Class
I create or rather allocate storage for the derived CWinThread class on the heap via new
after I create the CWinThread derived class suspended and set various members as the ipaddr
Then I do a Resumethread
in the CwinThread::Initinstance I do the CAsyncSocket::Create
this is where the issue is
while tracing the code under VS debugger the code jumps out the CWinThread::Initinstance
back to my main line loop
When I allocate a CAsyncSocket Class on the stack outside of the loop and do a Create
everything is cool
I get a return code of 1
|
|
|
|
|
Hi
I moved my code from the initinstance to the CWinThread constructer and it worked ?
Don't know why
|
|
|
|
|
What was the issue? ...you never actually say what the problem was.
|
|
|
|
|
Hi
I have a loop in my CWinApp::Initinstance where I create 4 Derived CWinThreads
a derived CAsyncSocket class is a protected member
When I step into with the debugger to the CasyncSocket::create it takes a wild which is in the CWinThread::Initinstance it takes a branch out the CWinThread::Initinstance back to the loop as if there some sort of exception I tried a try { around the code but it didn't go to the catch it just jumped out of the CWinThread::Initinstance back to the loop
for (i = 0, start_port = 11007; i < 4; start_port++, i++)
{
threadptr[i] = new SockCLeintThread(start_port);
if (threadptr[i] == NULL)
AfxMessageBox((LPCTSTR)"SockClientThreadFail",NULL,MB_ICONERROR);
ret = threadptr[i]->CreateThread(CREATE_SUSPENDED);
if(ret == 0)
errcd = GetLastError();
threadptr[i]->flags.is_connected = 0;
threadptr[i]->flags.busy = 0;
threadptr[i]->ResumeThread();
BOOL SockCLeintThread::InitInstance
{
AfxSocketInit();
ipaddr = (LPCTSTR)"10.0.0.205";
if(thisocket.Create(thisocket.port,SOCK_STREAM,(FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE),ipaddr)== 0)
{
error_code = thisocket.GetLastError();
}
DWORD value;
BOOL val, return_code;
const void *valptr = &val;
thisocket.AsyncSelect(FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE); val = 1;
return_code = thisocket.SetSockOpt(SO_KEEPALIVE,valptr,sizeof(BOOL)); val = 1;
return_code = thisocket.SetSockOpt(SO_OOBINLINE,valptr,sizeof(BOOL));
value = 1;
return_code = thisocket.IOCtl(FIONBIO,&value);
return_code = thisocket.IOCtl(FIONREAD,&value);
return_code = thisocket.IOCtl(SIOCATMARK,&value);
sockbuffer = new TCHAR[100];
}
When I move this code to the SockCLientThread constructor it works
|
|
|
|