|
WREY wrote:
would yield the result of the operation in GHCapturePt, and therefore setting the breakpoint at that line you'd get to see what GHCapturePt has in it???
Take it easy WREY. Normally debuggers (the ones that I have used at least) don't work that way. You get to see the results of a line after that line has been executed. Imagine for a moment if you wanted to set a breakpoin on the very first line of the code. Where would you put the breakpoint? Before the line? There is nothing before that. However, your mistake is very normal and I must admit that I make it too once in a while (but I know the answer when I don't see the right results).
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Since I've already solved the problem which prompted posting the message in the first place, this is just academic "after the fact" stuff.
I guess the whole thing comes down to a matter of interpretation. I interpreted setting a breakpoint as telling the computer, "At this point, stop, and let me see what you have, or what you've done up to this point." I didn't interpret it as, "... excluding this line." I interpreted it as, "up to this point including this line where the breakpoint is being set."
To take your example of setting the breakpoint at the first line of code (even if that first line of code is):
int GHCapturePt = len - diff;
(accepting that 'len' and 'diff' are global variables) I would think that the line will have been executed and the contents of all variables in that line would have legitimate results in them. That was my thinking, and I can see now, it really doesn't matter what someone thinks, what it comes down to, is the way the tool works.
William
Fortes in fide et opere!
|
|
|
|
|
Toni78 said it right: the way you think debuggers should work is not the actual way they work. The breakpoint is set on a line to break BEFORE the line is run. That way you can set the breakpoint, break at that line or code, then step to the next line and see what that line of code did. It seems rather silly to have a breakpoint AFTER the code you want to look at has already been executed.
I bet you and I have different meaning to the old "1,2,3, Go" conundrum. Is it: "1,2,3, THEN Go", or is it: "1,2,3, GO on 3".
The kindest thing you can do for a stupid person, and for the gene pool, is to let him expire of his own dumb choices.
[Roger Wright on stupid people]
|
|
|
|
|
I am reading in a file and trying to put words read in a char[].
My array in within a struct and the notation is:
struct TSimHeader
{
char Name[47];
char Unit[47];
double Min[47];
double Max[47];
int SignalCount;
int SimStatus;
int simdkid;
int modmode;
int write;
int call;
}static TSimHeader_arr[10];
This is where I read in the file and try to put the values in the appropiate containers:
string name, unit,min,max,value;
for(int i=0; i<47; i++){
getline(fin, name, ',');
if(name == "STOP")
break;
getline(fin, unit, ',');
getline(fin, min, ',');
getline(fin, max, ',');
getline(fin, value);
strcpy(TSimHeader_arr[0].Name[i], name.c_str());
strcpy(TSimHeader_arr[0].Unit[i], unit.c_str());
TSimHeader_arr[0].Min[i] = atof(min.c_str());
TSimHeader_arr[0].Max[i] = atof(max.c_str());
TSimSignal_arr[0].Value[i] = atof(value.c_str());
sig_count ++;
}
The error I get is:
:*.cpp(104) : error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *'<br />
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Thanks for the help,
Steven
|
|
|
|
|
Here's your problem: strcpy() copies the contents from one character-array to another. in the string class, c_str points to the char-array (which is good).
However, you're telling strcpy() to copy the contents of c_str to a single character in the array (Name[i] signifies the i-th character in Name).
Looking at your strcuture, it "LOOKS" like Name and Unit are supposed to be character-arrays (strings) of length 47, and there are 10 elements of type TSimHeader, which equates to 10 character-arrays (string) of length 47.
If this is the case, you must change the loop for 10 entries instead of 47.
string name, unit,min,max,value ;
for(int i = 0 ; i < 10 ; i++){
getline(fin, name, ',') ;
if(name == "STOP")
break ;
getline(fin, unit, ',') ;
getline(fin, min, ',') ;
getline(fin, max, ',') ;
getline(fin, value) ;
// The following assumes that name and unit
// are less than 47 characters long
strcpy(TSimHeader_arr[i].Name, name.c_str()) ;
strcpy(TSimHeader_arr[i].Unit, unit.c_str()) ;
TSimHeader_arr[i].Min[i] = atof(min.c_str()) ;
TSimHeader_arr[i].Max[i] = atof(max.c_str()) ;
TSimSignal_arr[i].Value[i] = atof(value.c_str()) ;
sig_count ++ ;
}
Again, this is assuming I interpretted this correctly.
|
|
|
|
|
You are correct but, There are 47 names, units, min, max. At each (ith) position the data is related.
If I just run through the loop 10 times then I won't get the rest of the data all put in the correct array within the struct.
I have it working with a 2 dimensional array.
I have limited memory so I need to really be sparing on memory.
So, I really need to store the names and units in a single dimension array
I hope all of that made sense.
I have a feeling that it won't work.
thanks,
Steven
|
|
|
|
|
What good is a code snippet if you don't even know C++?
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
that's quite an order ... I feel nice today,
FindWindow can do that for ya' but I won't give more, you need to work on your c++ before continuing.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Yea, thats a great attitude, dude.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
After reading several boards, I'm close but no cigar. I have an existing C++ app that calls my vc6 dll which calls a vb6 dll. That seems to work fine but when I try to call a function in the vc dll from the vb dll. For this test, the calling vc app does a simple call to fakePlugIn().
The vc dll:
#include "stdafx.h"
#import "testvb.dll"
using namespace testvb;
extern "C" __declspec(dllexport) fakePlugIn()
{
HRESULT hresult;
CLSID clsid;
_vbdllcls *t;
CoInitialize(NULL); //initialize COM library
hresult=CLSIDFromProgID(OLESTR("testvb.vbdllcls"), &clsid);
hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_vbdllcls),(LPVOID *) &t);
if(FAILED(hresult))
{
AfxMessageBox("Creation Failed");
return false;
}
t->InVbDll("string to vb dll"); //call the vb dll
t->Release();
CoUninitialize();
return true;
}
extern "C" void __declspec(dllexport) Callback(void)
{
AfxMessageBox("in callback");
}
The vb code:
Public Declare Function Callback Lib "testcpp.dll" () 'this is in a module
Public Function InVbDll(ByVal s As String) As Long 'this is in class vbdllcls
MsgBox s
Callback
End Function
With Callback defined as __declspec(dllexport), the message box in Callback gets executed but then I get a runtime error: Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.
OK so I tried __stdcall instead. Then I don't make it to the Callback and get a runtime error:
First-chance exception at 0x77e73887 in cppshell.exe: 0xC000008F: Floating-point inexact result.
First-chance exception at 0x77e73887 in cppshell.exe: Microsoft C++ exception: _com_error @ 0x0012fbac.
I've tried various combinations as well with the same result. Ultimately, I'd like to pass strings into and possibly out of Callback, but one step at a time.
Any light you could shed on this would be appreciated!
|
|
|
|
|
.... you have already run the App Wizard without including database support?
I have a DB project that is Dialog based from the App Wizard. It is replete with calls to create CDatabase and CRecordset objects and I am manually building the query strings and calling ExecuteSQL(); everywhere. It works, but is rapicly getting unmanageable. I would very much like to associate dialog boxes with a CRecordset member variable like the App Wizard does for you if you select a DB app.
SHould I just throw away all the work I have done and restart, or is there a way to include DB support for dialog boxes after the fact?
|
|
|
|
|
I am working on an MDI MFC app and have been making great progress on it, but all of sudden, when I try to use my vertical scroll bar to scroll the rich edit view, it doesn't respond. Mind you, I can still use the mouse wheel to scroll up and down, but not directly by using the vertical scroll bar.
It was working fine up until yesterday (been working on this project for roughly 2 months) when I must have changed something or adding something to the code that screwed it up, but for the life of me, can't figure out what. Please help!
Any suggestions as to what to change or edit I would appreciate!
|
|
|
|
|
Hi
does ne1 know the best way in c++ to detect if i have
a network connection, ie. connected to the internet
thanks
si
|
|
|
|
|
Does this help?
http://www.pcausa.com/resources/InetActive.txt
|
|
|
|
|
|
i dont know about the other replies and if the info there works everytime but i found the most reliable way was to try to ping a site that (hopefully) wont be down
if theres a better way they invented recently i'll be happ to know about it too
"there is no spoon" biz stuff about me
|
|
|
|
|
I've been using the following function with success. It returns
TRUE if a connection is available, and takes less than
a sec in either case:
<br />
BOOL Online()<br />
{<br />
DWORD dwState = 0; <br />
DWORD dwSize = sizeof(DWORD);<br />
return InternetQueryOption(NULL,<br />
INTERNET_OPTION_CONNECTED_STATE, &dwState, &dwSize)<br />
&& (dwState & INTERNET_STATE_CONNECTED);<br />
}<br />
Credit: I got this from Paul Dilascia's column in MSDN mag a while
back.
|
|
|
|
|
hi,
does anybody know how to install the TCP/IP via C++?
furthermore, i have to know how to set the IP number and anything like this...
Thx
CND
|
|
|
|
|
I don't think this is going to be an easy task. Different versions of windows (even service packs) have different dialogs and setup. I think Win 2K+ comes with TCP/IP installed by default. As for the IP address there are programs on this site that will do that for you. One thing to note is you can not assume that a person has 1 network card they may have 0 or 2.
John
|
|
|
|
|
Does anyone know if GDI+ 1.1 is included in the latest platform SDK. It is not part of VS.NET 2003 which is still using 1.0. The MSDN doco refers to 1.1 for a number of classes that I'm interested in.
There seems to be no information about it on the MSDN website (although it's hard to tell with the current search engine).
A few postings in newsgroups seem to indicate that the only source of this at the time of writing is as part of one of the Office 2003 products, does anyone know if this is the case.
Ta,
Jason Wilden.
Displaced Aussie. Currently in London, normally living in Melbourne.
modified 10-Jul-19 21:02pm.
|
|
|
|
|
I think it should come with the latest Platform SDK. I have it, and I think I got it by downloading the Windows Server 2003 RC2 SDK.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
jdunlap wrote:
I have it,
How do you know you have version 1.1 ?
None of the headers i have contain version information.
The dll version is 5.1.3097.0 which doesn't tell me if it's version 1.0 or 1.1 of the API.
I have the Feb.2003 Platform SDK installed.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Up until this time, i've been programming with turbo c from 100 years ago, and i haven't had any luck communicating with a meter. The code is not the problem, we've gotten similar programs to work, but we want to try using c++ to code in.
I've been using the bioscom() function of tc, which is very easy, but now that we're looking at c++, i haven't found anything similar.
Can someone point me to somewhere that has a general description of how so use c++ to communicate with a serial port?
*.*
cin >> knowledge;
|
|
|
|
|
|
In Win32 API you use CreateFile() to open the port. Look at the docs for that. ReadFile() and WriteFile() are used to send and receive data. CloseHandle() closes the port.
John
|
|
|
|
|