|
johnstonsk wrote:
char Name[5];
char Unit[5];
Actually, it should be:
char *Name[5];
char *Unit[5]; since C strings are a pointer to an array of characters. Then do this:
s.Name[i] = strdup(name.c_str());
s.Unit[i] = strdup(unit.c_str()); Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
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"
|
|
|
|
|
|
@Ryan : After using the "show me all" routine :
for(int i=0; i<sizeof(s.Name); i++){
getline(fin, name, ',');
if(name == "STOP")
break;
getline(fin, unit, ',');
getline(fin, min, ',');
getline(fin, max, ',');
getline(fin, value);
~RaGE();
|
|
|
|
|
Perhaps Chris should add a script that automatically converts '<' and '>' in <pre> tags to HTML character codes .
and possibly '&' as well
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
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"
|
|
|
|
|
I wish he did that. I know you can say no html that looks ok but if you want to use the <pre> tags it is a pain to edit your code samples..
John
|
|
|
|
|
What is the format of mockData.dat?
|
|
|
|
|
pla,deg,0.0,130.0,0.0
pitch_stickF,lbs,-3.28,4.4,0.0
roll_stickF,lbs,-13.0,13.0,0.0
yaw_pedal,lbs,-3.87,3.87,0.0
spbrk_pos,retract.hold.extend,-1.0,1.0,0.0
STOP,1
This is just a test file. The actual file has around 500 lines.
sj
|
|
|
|
|
This is not the recommended way to do what you are doing, but I just wanted to show you an alternative.
struct TSimSignal
{
double Min;
double Max;
double Value;
char Name[32];
char Unit[32];
} t[500];
FILE *pFile;
for (int x = 0; ...)
{
sscanf(pFile, "%[^,],%[^,],%f,%f,%f", t[x].Name, t[x].Unit, &(t[x].Min), &(t[x].Max), &(t[x].Value));
}
|
|
|
|
|
Instead of putting "i<sizeof(s.Name)" in your for loop, use "i<sizeof(s.Name)/sizeof(string)". sizeof() gives you the size of the variable/type in bytes , not the number of elements in the array. The size of a string is at least 4 bytes, so your loop will go at least 20 times - 5*sizeof(string). Your memory will therefore be overwritten by any writes after the 5th loop, and you'll end up with rubbish.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
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 Ryan it works great.
Is there anyway that I can read the file and the items read in are chars instead of strings?
You da' man,
Sj
|
|
|
|
|
johnstonsk wrote:
Is there anyway that I can read the file and the items read in are chars instead of strings?
There is, but I don't really think there's a lot of merit in doing so. Using the string functions is safe - it prevents buffer overflows by allocating just the right amount of memory. Trying to allocate memory yourself is just a PITA and can cause all sorts of security errors. I would stick with what you're doing. If it works safely, there's not much point changing it.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
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"
|
|
|
|
|
I want to paste a icon from resource to a button by using SetIcon(), but neither m_bttnOpen.SetIcon(AfxGetApp()->LoadIcon(IDI_ICON_OPEN));
nor
m_bttnOpen.SetIcon(::LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON_OPEN)));
can do this.
Why?
And how to do this by the most simple way?
thankx
|
|
|
|
|
olinn wrote:
Why?
Has your button the icon style checked ? (Go in the ressource editor, right click on your button, tab "styles", check "Icon").
olinn wrote:
And how to do this by the most simple way?
This one :
m_bttnOpen.SetIcon(::LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON_OPEN)));
~RaGE();
|
|
|
|
|
I know that ASCII numbers 27 and 28 represent up and down arrows. Is there a way to get these symbols into a CSTring?
thanks
|
|
|
|
|
CString cUpDown = "\x1B Up and down arrows \x1C";
onwards and upwards...
|
|
|
|
|
Thanks for your reply, but the resulting string just has dark black lines were I was hoping to see arrows.
|
|
|
|
|
That is dependent upon which font you are using to display the text. Look at the CharMap application. Some fonts have corresponding characters for ^ and v, some don't.
onwards and upwards...
|
|
|
|
|
|
Dear everyone,
I create some CEdit box, the height for example is 20.
and the CEdit box is not multi-line.
But the font size is small, for some function, should
set the text content verticle center or bottom in CEdit.
How can i do?
Welcome any suggestion!
Many thks to u!
Best Regards,
Bosicat
Good Luck
|
|
|
|
|
Sorry, you can't centre the text in an edit box. It can't be aligned with the bottom either. Top-only, I'm afraid
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
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"
|
|
|
|
|
|
Thomas George wrote:
Do anyone know of a way to set different background and foreground colors for the text on individual toolbar buttons?
WM_CTLCOLOR?
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
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"
|
|
|
|
|
|
I got a class declared as follows:
class CWordItemList : public CList<CWordItem*,CWordItem*&>{
public:
void AddTail(CWordItemList* pList);
...
};
void CWordItemList::AddTail(CWordItemList *pList)
{
CList<CWordItem*,CWordItem*&>::AddTail(pList);
//the program asserts(ASSERT_VALID) and throws an error
...
}
How should I derive from CList?
|
|
|
|
|
is there a possibility to easy edit a 24bit toolbar in VS.NET?(by editing i mean settind the IDs, rearrange the order,etc..) i cant believe this is not possible, and i have to rearrange, and cut my nice 24 bit toolbar "by hand"
why is there no support for 24bit toolbars??
greets andreas
|
|
|
|