|
C-style strings don't work like that. You should be using std::string unless there is an overriding reason not to:
std::string FileString;
std::string Buffer = "some stuff...";
FileString = "//" + Buffer;
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Thanks guys,
I tried not to use std::string as I am not sure if it's portable to Embedded Visual C++. I am doing the program using Visual C++ and expecting to make it workable on iPAQ when re-compling.
|
|
|
|
|
AFAIR STL is not avaliable in eMbedded Visual C++
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
strcpy(FileString, "//");
strcat(FileString, (char *) Buffer);
Brian
|
|
|
|
|
I'm struggling on this one... appreciate any hints you experts can offer.
Just trying to print out a histogram, using asterisks, to show the number of times each number 2-12 was rolled, after 50 rolls. I created the following two loops and cannot get the asterisks to continue to the next line as appropriate
<br />
max = maximum (frequency, arraySize); <br />
<br />
for (int countDown = max; countDown >= 0; countDown--)<br />
<br />
for (int j = 0; j < (arraySize-2); j++) <br />
<br />
if (frequency[j+2] <= countDown)<br />
cout << setw(3) << "*" << " ";<br />
<br />
else<br />
cout << setw(3) << " " << " ";<br />
<br />
<br />
for (face = 2; face < arraySize; face++)<br />
cout << setw(3) << face << " ";<br />
I tried adding an if statement---> if (j%10 == 0) cout << endl;
doesn't work.
Any suggestions?
Thanks so much!
Sheshi
|
|
|
|
|
When writing a for loop you need to use the curly braces when your statements within that for loop extend beyond 1 line. The two examples are the same, writing a new line doesn't occur until after the inner for loop has completed:
for(int i = 0; i < 10; i++)
{
for(int j = 0; j < i; j++)
{
cout << "*";
}
cout << endl;
}
or
for(int i = 0; i < 10; i++)
{
for(int j = 0; j < i; j++)
cout << "*";
cout << endl; <font color="green">
}
-Nick Parker
|
|
|
|
|
Thanks Nick! That gets me one step further to figuring this thing out!;)
Sheshi
|
|
|
|
|
I wanna use HOOK to catch the BM_SETSTATE message of a button,and i don't wanna return it to the button.i catch the BM_SETSTATE and did't return ::CallNextHookEx(hHook,nCode,wParam,lParam);
but the message is still pass to the button when i push "OK" of the Messagebox.
Pls. see my code here:
LRESULT CALLBACK CallWndProc(int nCode,WPARAM wParam,LPARAM lParam)
{
if(nCode != HC_ACTION)
{
return ::CallNextHookEx(hHook,nCode,wParam,lParam);
}
if(nCode == HC_ACTION)
{
pCwp = (CWPSTRUCT *)lParam;
if((wParam == 0) && (pCwp->message == BM_SETSTATE))
{
TRACE(childWinList[107].winText);
//MessageBox(NULL,childWinList[107].winText,childWinList[110].winText,MB_OK);
::SendMessage(pCwp->hwnd,WM_GETTEXT,256,(LPARAM) b);
CString a = b;
if (a == "Confirm Load")
{
GetWindowsList();
if (childWinList[107].winText != childWinList[110].winText+"_"+childWinList[89].winText)
{
if (!bShow) return -1;
bShow = 0;
if(IDOK == MessageBox(NULL,"The device Number and program name do not match!",b,MB_OK))
{
bShow = 1;
}
return -1;
}
}
}
}
return ::CallNextHookEx(hHook,nCode,wParam,lParam);
}
|
|
|
|
|
I'm developing an app in VC6 & MFC where I'd like to ship multiple versions of the software utilizing the same base source code. By multiple versions, I mean two variations of the same application. One version will be like a "Basic" version and another will be an "Advanced" version. So basically the same idea as Windows 2000 Pro and Windows 2000 Server. Both pieces of software utilize the same base code, generally speaking, but have different features available.
I'm looking for ideas, methodologies, approaches, design, etc. on how to implement this. Is the only answer preprocessor directives? What about some type of plug-in approach? The result needs to be able to modify the UI (menu bar, menu items, etc.) I've done a little research on the web but haven't found a "clean" approach to this problem. Help! Thanks
|
|
|
|
|
My article may be of use:
Plug-in architecture for MFC[^]
sounds to be what you need.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
I'm using the DeleteFile Function in an attempt to delete the program that is running. How can a program delete itself? I tried renaming the executable before deleting it, and it does is rename it but doesn't delete it. I suspect you can't delete an open file or program in NT, but I'm sure someone here has found a way to make a program delete itself aka uninstaller..
Any help would be thouroughly appreciated. Thanks in advance friends!
|
|
|
|
|
The easiest way is to create a batch file (.bat), from your program, start the batch file and exit your program.
In the batch file you loop until you can delete the programfile, and you delete the batch file (it can delete itself, a running program can not)
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
|
Consider this function
copyString(char *dest , char *source)
The minimal code to perform this copy is
copyString(char *dest , char *source) <br />
{<br />
while(*dest++=*source++);<br />
}
which can also be written as
copyString(char *dest , char *source) <br />
{<br />
while((*dest++=*source++)!=0);<br />
}
Now consider two strings
dest = <undefined>;<br />
source="sensibleString\0...garbage;
How does the while loop override the asignment operator = and copy only till the source is '\0';
My question is that I need a reason for the loop not to be running infinetely
Doesn't the while loop keep running till the assignment succeeds ? i.e how are garbage values after '\0' not being copied into source ?
Please help me solve this doubt !
|
|
|
|
|
act_x wrote:
How does the while loop override the asignment operator = and copy only till the source is '\0';
it doesn't.
in C/C++, the 'result' of an assignment is equal to the right side of the assignment.
in other words:
int a,b,c;
a = 5;
b = 10;
c = a = b;
so, the loop runs until the 'result' of the assignment is 0.
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|
|
Remove the ";" at the end of the line of the while loop. There is not ";" after a loop.
while((*dest++=*source++)!=0)
{}
What do you have "0" instead of "\0" in the while loop?
while((*dest++=*source++)!= "\0")
{}
Kuphryn
|
|
|
|
|
Hi All, wondering if someone could take a look at the following program and give me any hints/insight as to why I can't get the appropriate amount of asterisks to print above each number.
This program rolls two dice and is supposed to calculate the number of rolls for each number 2-12, and show that in a histogram.
Any suggestions? THANK YOU for any help!
<br />
#include <iostream><br />
<br />
using std::cout;<br />
using std::cin;<br />
using std::endl;<br />
<br />
#include <iomanip><br />
using std::setw;<br />
<br />
#include <ctime><br />
<br />
const int arraySize = 13;<br />
const int maxRolls = 50;<br />
<br />
int maximum (int [], int);<br />
int histogram(int [] [arraySize], int [], int, int);<br />
<br />
int main()<br />
{<br />
srand(time(0));<br />
int face, max, frequency[arraySize] = {0};<br />
<br />
for (int i = 0; i < maxRolls; i++) <br />
++frequency[(1 + rand() % 6) + (1 + rand() % 6)];
<br />
cout << "Below shows random results of rolling a pair of die 50 times" << endl;<br />
cout << "along with the number of times each number (2-12) was rolled." << endl;<br />
<br />
max = maximum (frequency, arraySize);<br />
int table [maxRolls] [arraySize] = {0};<br />
histogram (table, frequency, max, arraySize);<br />
<br />
for (face = 2; face < arraySize; face++)<br />
cout << setw(4) << face << " ";<br />
cout << endl << endl;<br />
<br />
return 0;<br />
}<br />
<br />
int maximum (int x[], int size)<br />
{<br />
int swap;<br />
<br />
for (int i = 0; i < (size-1); i++) <br />
<br />
for (int j = 0; j < (size-1); j++) <br />
<br />
if (x[j] > x[j+1]) <br />
{<br />
swap = x[j];<br />
x[j] = x[j+1];<br />
x[j+1] = swap;<br />
}<br />
<br />
return x[size-1];<br />
}<br />
<br />
int histogram (int y[] [arraySize], int frequency [], int max, int size)<br />
{<br />
int start = maxRolls - max;<br />
<br />
for (int i = start; i < maxRolls; i++)<br />
<br />
for (int j = 0; j < size; j++)<br />
<br />
if (frequency [j+2] <= max)<br />
cout << y[i][j] << setw(4) << "*";<br />
<br />
else<br />
cout << y[i][j] << setw(4) << " ";<br />
<br />
cout << endl;<br />
<br />
return 0;<br />
}<br />
Sheshi
|
|
|
|
|
Sheshi wrote:
for (int i = 0; i < maxRolls; i++)
++frequency[(1 + rand() % 6) + (1 + rand() % 6)]; //generates all rolls, places data in array
This looks like homework, however I would assume you want to do something like:
++frequency[i] = (1 + rand() % 6);
b/c with what you typed, your not storing anything within the array.
-Nick Parker
|
|
|
|
|
Three things:
- Your maximum function sorts the array passed in, totally destroying your data.
- You initialize your table array to all zero, and never add anything to it. What's the use of that?
- in your histogram function, you have if (frequency [j+2] <= max) . This line will *always* be true.
Your basic logic here is flawed. You initialize the frequency array just fine, but you are messing up your data and display code.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Not really sure where this should go but I thought I'd ask here first. Does anyone know how I can make an installer for my IE Deskband (Toolbar)?? All I have to do is compile the code and it automatically works on my computer but how do I make it install onto another person's computer? Thanks for any help.
|
|
|
|
|
regsvr32 [dll name]
many installation tools have an option to autoamtically register ( call DllRegisterServer ) of dlls included in the install package.
to remove the toolbar you need to call DllUnregisterServer. for example by using regsvr32 again with the /u parameter.
|
|
|
|
|
Visual Studio Installer is a good free setup creator program. It builds Windows Installer files (*.msi) and automates some of the more complex parts.
It is available from Microsoft at:
http://msdn.microsoft.com/vstudio/downloads/tools/vsi11/default.asp
Do unto others as you would have them do unto you - Jesus
An eye for an eye only makes the whole world blind - Mahatma Gandhi
|
|
|
|
|
hi programming freaks,
i make a win32 header and related cpp classes and make a dll .Ok.
now when i want to use the dll in other application i include headers and i think everything is ok ,but visual stadio.net throw me a LNK2019 fatal error.
i don't know what's wrong .
thank u in advance .
please give me a clue!
|
|
|
|
|
rzitman@yahoo.com wrote:
i don't know what's wrong .
Are you working under a managed environment with VS.NET? If so you need to use P/Invoke.
-Nick Parker
|
|
|
|
|
no ,look i use win32 projects .
u know my problem is that my newly made dll isn't loaded in my program properly .
compiler throw me some fatal errors like i can't find the dll .
in a nutshel:
my DLL makeing project :
neededheader.h
relativecpp.cpp
madeDLL.dll
now my test project:
neededheader.h
madeDLL.dll
testcpp.cpp
-----------------
Nick could u shed me a light in this issue?
|
|
|
|