|
If you're into Object Oriented programming, you might want to try UML. It's helpful for breaking large ideas into smaller chunks.
There are a number of UML tools available. ArgoUML is pretty nice, and free, too. http://argouml.tigris.org/
|
|
|
|
|
|
i just started learning c++ so it may just be a noob question but i am haveing a problem. I am trying to make a prog that writes names and number to notepad. When i run it it write the names and number but on top of it it has a set of numbers (1245068) and that will happen everytime.
Example:
1245068
John
Doe
5678906
Jaine
Doe
23456789
That is what is on notepad. My question is what i am doing wrong to get that set of number and how to just write the first name then last name then number. If anyone could help it would be appreciated. my code is bellow.
#include<stdlib.h>
#include<iostream.h>
#include<fstream.h>
int main(int argc, char* argv[])
{
int x=0, y=0;
string L_Name[100];
string F_Name[100];
int number[100];
char resp;
//Reads if there is already info in there and puts it into array
ifstream read("File.txt");
while(!read.eof())
{
read >>F_Name[x] >>L_Name[x] >>number[x];
x++;
}
read.close();
//Where the user can enter more name
do
{
cout <<"First Name: ";
cin >>F_Name[x];
cout <<"Last Name: ";
cin >>L_Name[x];
cout <<"Number: ";
cin >>number[x];
x++;
cout <<"Would you like to enter another name?(y/n)";
cin >>resp;
}
while((resp=='y')||(resp=='Y'));
y=x;
//writes the origianl names then the new name but here is where i get the
//set of numbers
ofstream write("File.txt");
for(x=0; x<y; x++)
{
write <<F_Name[x] <<endl;
write <<L_Name[x] <<endl;
write <<number[x] <<endl;
}
return 0;
}
|
|
|
|
|
Try it without the endl, if not copy declare a CString and append the name, last name and the phone number into a string and just write the string.
CString temp_string;
temp_string = "";
while.....
temp_string = F_Name[x] + " " + L_Name[x] + " " + number[x];
write<
|
|
|
|
|
OK, let's have a look.
You included iostream.h and fstream.h, you should just include iostream and fstream ( drop the h ). The .h versions are the ones created prior to the standard. I think you'll find that you'll then need to put using std::cin;, etc. for all the parts of iostreams you use. Namespaces are just one benefit of using standard headers.
You should also investigate using std::vector to hold your data, and probably put it in a struct. The first so you don't have a limit to how many items can be entered, the second to connect the three pieces of data you collect.
I dunno what your main problem is though, I'd try flushing the stream perhaps (cin.flush() from memory), or perhaps using the standard C++ headers will even solve the problem.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
ya i tryed putting it in a stuct but it would do the same thing so i just tryed it with it out
|
|
|
|
|
The struct won't solve your problem, it merely makes your design better. Add an iostream inserter/extracter and things would be really nice.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I know in c++ you could use setpercision to change the number of decimal places outputted. So how do you do it with the Cstring variable output in a dialogbox in mfc?
I have the following:
float Float_Percentage=0;
float_percentage = m_wins/m_plays;
CString PercentageConversion;
PercentageConversion.Format("%f",Float_Percentage); // convert float to str
percentvalue=PercentageConversion; // percent is of type CString
I get output like this 0.050000
How do i make it 0.05 as in just show two decimal places in a setpercision(2)?
Thanks for your help.
Win32newb
"Making (C)Windows programs worse than they already are!"
|
|
|
|
|
Use "%.2f" instead of "%f" to format the value.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
thanks for the help that worked
Win32newb
if (user=="Win32newb")
{
CWnd::Messagebox
("DUH");
}
ELSE
{
CWnd::Messagebox
("HELP WIN32NEWB");
}
"Making windows programs worse than they already are"
|
|
|
|
|
I have a SDI and I dont override the standard file open ( i.e CWinApp::OnFileOpen() ), I do however use a separate CFileDialog to open a particular type of file.
When I use the CFileDialog to open my files I set the initial directory to open from (different from the executable dir). Then when I use File->Open it uses the CWinApp::OnFileOpen and the initial directory is the last directory from my CFileDialog, I expect this.
However I used SetCurrentDirectory to reset this directory but it still uses the previous value. It also uses this value when I retart the program and choose file->open.
How can I set this to always open in the executable directory for file->open. I dont want to override the OnFileOpen and use a CFileDialog.
---
|
|
|
|
|
Here's my code
int ParsePacket(BYTE *aPacket,short int iStartPos);<br />
<br />
<br />
void main()<br />
{<br />
BYTE aPacket[] = {0x59,0x89,0x59,0x59,0x23,0x59,0x59,0x59,0x89,0x59,0x00,0x54,0x65};<br />
int l = ParsePacket(aPacket,5);<br />
printf("%d\n",l<br />
system("pause");<br />
}<br />
<br />
<br />
<br />
int ParsePacket(BYTE *aPacket,short int iStartPos)<br />
{<br />
bool bFound = false;<br />
int iPos = 0;<br />
<br />
for (int i = 0;i < (sizeof(aPacket) - 1); i++)<br />
{<br />
printf("Test: %x\n",aPacket[i]);<br />
}<br />
<br />
return iPos;<br />
}
This piece of code should output twelve values ( sizeof(aPacket) = 13 ), but instead it only outputs the first three bytes of aPacket... why?
|
|
|
|
|
TO get a hint as to the problem, you should have added an printf for "sizeof(aPacket)". In the context of the ParsePacket function, sizeof(aPacket) is 4, because ParsePacket recieves aPacket as a BYTE *, and on the 32-bit x86 architecture, all pointers are 4 bytes. The sizeof operator has no way of determining the length of an array pointed to by aPacket.
i.e.:
//-----
#include <windows.h>
#include <stdio.h>
int ParsePacket(BYTE *aPacket,short int iStartPos);
void main()
{
BYTE aPacket[] = {0x59,0x89,0x59,0x59,0x23,0x59,0x59,0x59,0x89,0x59,0x00,0x54,0x65};
printf("size (in main): %i\n",sizeof(aPacket));
int l = ParsePacket(aPacket,5);
printf("%d\n",l);
system("pause");
}
int ParsePacket(BYTE * aPacket,short int iStartPos)
{
bool bFound = false;
int iPos = 0;
printf("size (in ParsePacket): %i\n",sizeof(aPacket));
for (int i = 0;i < (sizeof(aPacket) - 1); i++)
{
printf("Test: %x\n",aPacket[i]);
}
return iPos;
}
//-----
outputs:
-----
size (in main): 13
size (in ParsePacket): 4
Test: 59
Test: 89
Test: 59
0
Press any key to continue . . .
-----
You need to pass the length of the array to the ParsePacket method.
i.e.:
//-----
#include <windows.h>
#include <stdio.h>
void ParsePacket(BYTE *aPacket,int aPacketLength);
void main()
{
BYTE aPacket[] = {0x59,0x89,0x59,0x59,0x23,0x59,0x59,0x59,0x89,0x59,0x00,0x54,0x65};
ParsePacket(aPacket,sizeof(aPacket));
system("pause");
}
void ParsePacket(BYTE * aPacket,int aPacketLength)
{
for (int i = 0; i < aPacketLength; i++)
{
printf("Test: %x\n",aPacket[i]);
}
}
//-----
outputs:
-----
Test: 59
Test: 89
Test: 59
Test: 59
Test: 23
Test: 59
Test: 59
Test: 59
Test: 89
Test: 59
Test: 0
Test: 54
Test: 65
Press any key to continue . . .
-----
|
|
|
|
|
I didn't know that
Thanks a lot
|
|
|
|
|
You're very welcome. Glad I could help.
|
|
|
|
|
Hi!
The Hebrew version of my software works fine on Win XP English and Hebrew but it will display gibberish on Win98 Enabled and Hebrew. It will even mess up the fonts for the complete OS.
I havent seen the problems myself, I have someone over in Israel that is testing for me.
Is there anything to take care about for Win98 Enabled and Hebrew?
Thanks!
---------------
Tired of Spam? InboxShield for Microsoft® Outlook® and Outlook Express®
http://www.inboxshield.com
|
|
|
|
|
This is my dilema. I have somethings I'd like to accomplish. The first thing is to get stars(*) to appear when someone puts in thier pin(it's an ATM program). I haven't quite figured it out and I need help understanding it. The next thing would be help with sub-classing. I read a couple of articles on it. NCP(Number, Currency, Percentage) edit controls. The other article I read was on sub-classing. I have an understanding(I don't know for 100% though) of sub-classing for buttons. I've tried doing the same thing for edit controls but I'm having problems understanding it. I'm using Dialog Boxes. Thanx to those to have helped me before and thanx to those who wrote those articles they helped. Thanx for your time and help.
Sincerely
David "Ice"Berg
quake3b@yahoo.com
|
|
|
|
|
As for your password problem. If you go to your dialogbox and the edit box you just made. Do the following.
Right click on the edit box and go to properties. Then go to style. Put a check mark in password and then whenever you type anything in the edit box you will get ***'s. Hope this helps.
Win32newb
if (user=="Win32newb")
{
CWnd::Messagebox
("DUH");
}
ELSE
{
CWnd::Messagebox
("HELP WIN32NEWB");
}
"Making windows programs worse than they already are"
|
|
|
|
|
I'm looking for an interactive 2d graph control, but the ones in the miscellaneous controls category all seem to be static. By interactive, I mean having the ability to select and move the graphed points with the mouse.
Any ideas?
-- K
|
|
|
|
|
I'm hosting MSHTML in an Explorer bar, and a specific Web page is causing a crash in MSHTML. No other page has done that for me. I'm trying to figure out why it's happening, but I can't make sense of the call stack. MSHTML is hosted with a download control which should be preventing dynamic content from being displayed/executed, so it's curious why the call stack appears to be attempting to process some window message. Or maybe not. Any pointers? Thanks!
Here's the call stack I obtained from VS.NET:
> MSHTML.DLL!CElement::BecomeCurrent() + 0x50
MSHTML.DLL!CElement::BubbleBecomeCurrent() + 0x61
MSHTML.DLL!CMarkup::NavigateHere() + 0x47e69
MSHTML.DLL!CTaskLookForBookmark::OnRun() + 0x42
MSHTML.DLL!CTask::TaskmanRunTask() + 0x34
MSHTML.DLL!CTask::TaskmanRun() + 0xb1
MSHTML.DLL!CTask::OnTaskTick() + 0x5
MSHTML.DLL!GWMouseProc() - 0x1f0a99
MSHTML.DLL!GlobalWndProc() + 0xf9
user32.dll!_InternalCallWinProc@20() + 0x1b
user32.dll!_UserCallWinProcCheckWow@32() + 0xb7
user32.dll!_DispatchMessageWorker@8() + 0xd8
user32.dll!_DispatchMessageW@4() + 0xb
ole32.dll!CDllHost::STAWorkerLoop() + 0x69
ole32.dll!CDllHost::WorkerThread() + 0xd6
ole32.dll!DLLHostThreadEntry() + 0x9
ole32.dll!CRpcThread::WorkerLoop() + 0x1e
ole32.dll!CRpcThreadCache::RpcWorkerThreadEntry() + 0x1a
kernel32.dll!_BaseThreadStart@8() + 0x37
I have a similar call stack from WinDbg:
# ChildEBP RetAddr Args to Child
00 0b4efbc0 6363aed8 00000000 0b4efbfc 00000000 mshtml!CElement::BecomeCurrent+0x77 (FPO: [Non-Fpo])
01 0b4efc00 636d13db 00000000 00000000 00000000 mshtml!CElement::BubbleBecomeCurrent+0x81 (FPO: [Non-Fpo])
02 0b4efca4 6373deba 00000000 08ebef24 00000000 mshtml!CMarkup::NavigateHere+0x39d (FPO: [Non-Fpo])
03 0b4efcc8 636b1c42 00336b8f 08e88380 00000064 mshtml!CTaskLookForBookmark::OnRun+0x42 (FPO: [Non-Fpo])
04 0b4efcd8 636b1bf6 08e88380 00336ac7 08e8c400 mshtml!CTask::TaskmanRunTask+0x34 (FPO: [3,0,2])
05 0b4efcfc 636b1b40 63581dc7 63677b41 000003e8 mshtml!CTask::TaskmanRun+0xe4 (FPO: [Non-Fpo])
06 0b4efd00 63581dc7 63677b41 000003e8 63581d1d mshtml!CTask::OnTaskTick+0x5 (FPO: [2,0,0])
07 0b4efd0c 63581d1d 000503a0 00002000 0b4efeac mshtml!GWMouseProc+0x115 (FPO: [2,0,0])
08 0b4efe38 77d43a50 000503a0 0000033d 00002000 mshtml!GlobalWndProc+0x193 (FPO: [Non-Fpo])
09 0b4efe64 77d43b1f 63581c24 000503a0 00000113 USER32!InternalCallWinProc+0x1b
0a 0b4efecc 77d43d79 00000000 63581c24 000503a0 USER32!UserCallWinProcCheckWow+0x150 (FPO: [Non-Fpo])
0b 0b4eff2c 77d43ddf 0b4eff50 00000000 771c97df USER32!DispatchMessageWorker+0x306 (FPO: [Non-Fpo])
0c 0b4eff38 771c97df 0b4eff50 00000000 00000000 USER32!DispatchMessageW+0xb (FPO: [1,0,0])
0d 0b4eff6c 771daf11 77e7a5a2 00007530 0a1297f8 ole32!CDllHost::STAWorkerLoop+0x5a (FPO: [Non-Fpo])
0e 0b4eff8c 771dae38 771e71a8 772bb908 771b0000 ole32!CDllHost::WorkerThread+0xda (FPO: [Non-Fpo])
0f 0b4eff90 771e71a8 772bb908 771b0000 0a1297f8 ole32!DLLHostThreadEntry+0x9 (FPO: [1,0,0])
10 0b4effa8 771e7207 00221e50 7b1b0b33 77e7d33b ole32!CRpcThread::WorkerLoop+0x1e (FPO: [EBP 0x0b4effec] [0,0,4])
11 0b4effb4 77e7d33b 0a1297f8 00221e50 7b1b0b33 ole32!CRpcThreadCache::RpcWorkerThreadEntry+0x1a (FPO: [1,0,2])
12 0b4effec 00000000 771e71ed 0a1297f8 00000000 kernel32!BaseThreadStart+0x37 (FPO: [Non-Fpo])
|
|
|
|
|
Hi, i´m having some problems to install a lsp on a Windows NT 4 Service Pack 6.
It´s Fail at WSCInstallProvider(...)
The Strange Thing is that LSP is working fine on Windows 2000, and Windows XP.
I Didn´t find any changes (prototype or argument numbers) related with this function.
Somebody here knows what could be happening ?
Thanks,
Victor
|
|
|
|
|
Hello
I want To Get The Folder Of My Application , The folder My .Exe File placed there.Buf with out using GetCurrentDirectory if Posible.
Iman Ghasrfakhri
|
|
|
|
|
GetModuleFileName should do the trick for you
"You know "that look" women get when they want sex? Me neither."
--Steve Martin
|
|
|
|
|
thancks alot
Iman Ghasrfakhri
|
|
|
|
|
I have a system tray icon that displays a menu when you right click on it, but it doesn't disappear when you click elsewhere on the screen.
To make it disappear you have to click an item on the menu.
Does anyone know why this is happening?
Thanks
|
|
|
|
|