I've been looking for the thread re swapping values of two string pointers but I couldn't findit and I don't know if it has already been solved. Assuming it's still on the lines waiting, I think I've got the simple code to solve it:
#include <windows.h>
void swap(LPCTSTR*,LPCTSTR*);
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
char szBuf[1024];
LPCTSTR ptr1 = "Pointer 1";
LPCTSTR ptr2 = "Other pointer";
wsprintf(szBuf, "This is the first order before calling swap():\n\nptr1: %s\nptr2: %s",
ptr1, ptr2);
MessageBox(0, szBuf, "swap demo", MB_ICONINFORMATION);
swap(&ptr1, &ptr2);
wsprintf(szBuf, "and after calling swap():\n\nptr1: %s\nptr2: %s", ptr1, ptr2);
MessageBox(0, szBuf, "swap demo", MB_ICONINFORMATION);
return 0;
}
void swap(LPCTSTR *ppstr1, LPCTSTR *ppstr2)
{
LPCTSTR ptemp = *ppstr1;
*ppstr1 = *ppstr2;
*ppstr2 = ptemp;
}
If there's an abvious reason why I came too late, think it's maybe because I don't have my own internet connection.