|
Bram van Kampen wrote: No harm intended though.
of course not - thats what makes it fun !
'g'
|
|
|
|
|
Bram van Kampen
|
|
|
|
|
Maybe you're single-stepping your keyboard too much?
|
|
|
|
|
No,
It is a Syntax Error: The OP Wrote:
if(X>Y){...}else(X<=Y){...}
The Compiler responded with Missing ';' before '{'
So he wrote:
if(X>Y){...}else(X<=Y);{...}
This makes it valid Code, but the final Block will never be executed.
Bram van Kampen
|
|
|
|
|
I was reacting on your "Happens often for some reason..."
the original problem has been solved already.
|
|
|
|
|
First a side comment on terminology.
rbwest86 wrote: int main()
{
//Global Declarations of Variables
double iovertime_hours=0;
double iovertime_pay=0;
These are actually automatic (local) variables, not global. There is nothing wrong with this - you normally do want to use automatic variables rather than global whenever you can.
Now to your question.
rbwest86 wrote: int cname ;
int ihours ;
int iwage ;
//Enter Employee Information
cout << "\n\nEnter the employee name = " ;
cin >> cname ;
Note that cname is an int. I would normally expect the response to the prompt to be a string. You are telling cin to expect only a number. Perhaps cname should be something like, oh, a std::string.
|
|
|
|
|
Thank you all so very much. I figured it out with the support of everyone here.
There were two major problems. Problem one was the:
int cname "this should have been a string"
The other problem was I included what should have been a comment:
else
{
code here
}
And thats it!
Thank y'all so very much. Now I gotta figure out a way to keep the console open that is not operating system Dependant, or should I say non-extended C++? I tried cin.get() and cin.ignore() but those didn't work and think they are OS Dependant.
V/R
Rob
|
|
|
|
|
Just to let everyone know, I included a do-while loop to ask the user if he wanted to include another entry. I did not want to use some sort of OS dependent rule to get my program to stop closing.
|
|
|
|
|
my code:
#include "stdafx.h"
#include <stdio.h>
#include <fstream>
void CParamDisplay::OnParamOpen()
{
CFileDialog cfiledlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT
, "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||", this);
if (IDOK == cfiledlg.DoModal())
{
m_filename = cfiledlg.GetPathName();
UpdateData(FALSE);
DisplayParam(m_filename);
}
}
BOOL CParamDisplay::DisplayParam(CString filename)
{
UINT sNum = 0;
CHAR paramId[MAX_BUF_SIZE] = _T("");
CHAR paramUnit[MAX_BUF_SIZE] = _T("");
FLOAT paramValue = 0;
FILE* pFile = fopen (filename, "r");
if(pFile == NULL)
return FALSE;
while(fscanf(pFile, "%d %s %s %f", sNum, paramId, paramUnit, paramValue) != EOF)
{
...
}
fclose(pFile);
return TRUE;
}
when i debug it, the app stopped at fscanf().and displayed:"Uhandled exception in XX.exe (MSVCRTD.DLL):0XC00000005:access violation".i can't fix it...(T_T)
i 've tried ,then i have no regret
|
|
|
|
|
what is MAX_BUF_SIZE defined as ?
what does your data in the file look like ?
the access violation reported is most commonly caused by overwriting memory somehow - not allocating it/enough - I can see you are allocating buffers for your char (string) arrays, but for instance if
MAX_BUF_SIZE was 5 and you had
1 thisisacharastring thisisanothercharstring 1.44
you'd see that the first %s in fscanf would get thisisacharastring which is a bit longer than 5
'g'
|
|
|
|
|
thank u, i've tried the Bram van Kampen's method,it works
i 've tried ,then i have no regret
|
|
|
|
|
try:
while(fscanf(pFile, "%d %s %s %f", &sNum, paramId, paramUnit, ¶mValue)...
Bram van Kampen
|
|
|
|
|
chuckle, I missed that one completely
'g'
|
|
|
|
|
Easy thing to Miss!
Chased one similar to that last week in my own code for 2 hours. At least the OP set it to '0' (NULL) to begin with. I had not done so, and made it far more difficult to trace.
Bram van Kampen
|
|
|
|
|
it works.it takes me about three hours to try to solve it.
thank u very mnuch.
i 've tried ,then i have no regret
|
|
|
|
|
Has anyone succeeded in getting the Visual C++ 2005 runtime or .NET 2.0 to work in Windows PE 2.0? Everything I've found online (such as here[^]) indicates no one has gotten this to work except some guy who goes by Zoronax, but he never described how he got it to work. I did find a plugin[^] that is supposed to work for PE 1.6, but not PE 2.0, so that does me no good
I'm trying to automate our workstation backups in Windows PE, and I need to determine which user belongs to a given machine. We figured the best way is to compare the MAC address against a text file that maps MAC address to user name. I tried doing this in a batch file using
FOR /F "tokens=2 delims=:" %%I IN ('ipconfig /all ^| find /I "Physical Address"') DO 'process file here' but the %%I variable has a trailing CR at the end and I can't seem to get rid of it. Since that wasn't working, I wrote a small C++ utility to do the comparison and display the user name. It works find in XP and Vista, but I get a "side-by-side configuration is incorrect" error in Windows PE. I assume this means I need to install the Visual C++ 2005 runtime. When I try to run the installer for it, though, msiexec throws a "File could not be found" error. Any ideas?
Thanks,
Dybs
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
modified on Monday, January 18, 2010 7:23 PM
|
|
|
|
|
After some more searching, I ran across this thread[^] that suggests using static linking. I'll give that a try tomorrow and see if I have any luck.
Dybs
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
I have done quite a bit of work with WinPE and yes statically linking the runtime is the best solution for your own code.
However standing back a second, you do know that you can add packages to the WinPE image and one of these is:
WinPE-Scripting
Windows Script Host (WSH) support. Enables batch file processing using WSH script objects.
So rather than going to the trouble of creating an executable you can use VBS or JS with Cscript.exe to do the work. This might give you mor felixibility in the long term.
Also watch out for dependancy issues. I have a WinPE image I use for data recovery, forensics and general stuff in which I use a number of freeware tools. A lot of these have late binding dependancies which, once you know what they are, are simple to resolve by copying the dependant DLL's in to the WIM.
Alan
|
|
|
|
|
Alan,
Thanks for the suggestions. I ended up going with VBScript and it works perfectly. I based my solution off of an Experts Exchange post from this Google search (9th entry from the top)[^].
Dybs
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
|
Put something like the following in a source file:
#ifdef MY_CONDITION
#pragma comment(lib, "libA.lib")
#else
#pragma comment(lib, "libB.lib")
#endif
If the lib(s) are included as dependent projects in the solution then you may need to disable auto linking of dependent projects in the project settings or it may try to link the wrong one.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Thanks for the reply.
I will try what you suggest.
|
|
|
|
|
For future reference, it is considered rude to delete your original question.
Now people can not read the forum, and see why you were helped, and they can no longer become wiser themselves.
The only reason to remove a message if if you were calling someone a rude name, and you regretted it later.
That said, I'm glad you were helped, and the world is a better place in your little corner.
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
Hi cmk.
Your suggestion did the trick - thanks
Tony
P.S. Appologies for deleting the original message - not quite sure how it happened
|
|
|
|
|
hello, i need to change the appearance of a spin control , is there any way to do this?
|
|
|
|