|
A matrix is the same as a two dimensional array. Do you know what that is ? Your teacher obviously thinks you should.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Two Dimensional array....hmmmmm.....never heard of it, but I'll look it up. Thanks Christian.
|
|
|
|
|
Ok, when I enter the below code, it says, subscript requires array or pointer type. What does that mean?
#include<iostream.h>
int r,c,x;
int a[100][100];
int b[100][100];
main(){
a[0][0] = 10;
a[0][1] = 11;
a[1][0] = 15;
a[1][1] = 21;
b[0][0] = 10;
b[0][1] = 11;
b[1][0] = 15;
b[1][1] = 21;
for (r=0; r<=4; ++r){
for (c=0; c<=5; ++c){
cout<
|
|
|
|
|
nywebhead wrote:
cout<<x[r][c]<<" ";<="" i="">
x is an integer.
Use a or b which you have declared as 2-d arrays
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Thanks, I figured it out. Geez, this is tedious.
|
|
|
|
|
nywebhead wrote:
Geez, this is tedious.
LOL
Don't worry. It'll get easier as you progress
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Changing the colors of buttons, and edit boxes is easy with Visual Basic, but I've grown up and am now using Visual C++. The problem I have now is that I have no clue on how to change the color of buttons and edit boxes.
Please, Gurus and Masters of C++, please almighty gods, tell me how I can do this. I will worship at your feet if I get a response. I am repentant of my VB ways and am now bowing before you.
|
|
|
|
|
You would either add a handler for OnCtlColor or make the button Owner Draw.
Also look at:
http://www.codeproject.com/staticctrl/coloredit_colorstatic.asp
http://www.codeproject.com/staticctrl/clabel.asp
Instead of using an Anonymous post you might like to Register here at CP which makes us CP regulars happier.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
Instead of using an Anonymous post you might like to Register here at CP which makes us CP regulars happier.
The bad thing about anonymous posts is that you dont get mail notifications
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I wish to capture keystrokes much like hot keys.
Instead of setting up buttons with captions like
&0Zero, &1One, ... &9Nine.
I would like to be able to capture keystrokes like
ALT 0, ... ALT 9.
I guess the PreTranslate() is the right place to do this.
My question is how do I tell that both the ALT key is down when the 0 key was pressed?
Please point me in the right direction.
Thanks
|
|
|
|
|
|
Michael Dunn wrote:
If your app is SDI or MDI, just create accelerators for those keystrokes.
Adding to what Mike said. If it a dialog based APP, you can read this article which shows how to have accelerator keys working in a dialog based app :-
http://www.codeproject.com/useritems/pretransdialog01.asp
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
For the life of me I can't remember how to do this... I am creating my own file format for a hobby application I'm working on and I am trying to remember how to store a 'C' constant string in an integer variable.
I have a dummy header for now defined as:
<br />
struct Header {<br />
int Identity;
int Version;
};<br />
I then proceed to store info but when I try to store SAM1 it doesn't seem to store everything. I'm just a little confused and don't remember how to do this, any help would be greatly appreciated. Or, any other method you suggest to store a string in the header file would be appreciated as well.
Thanks in advance.
Sam
----
"No special sig just plain old Sam..."
|
|
|
|
|
If the storage of id is limited in 4 letters, this way would do:
struct Header {
int Identity;
int Version;
};
Header hh;
memcpy(&hh.Identity, "SAM1", 4);
But I don't think int a good choice for the case...
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
Thanks for the heads up I would of never guessed that even after seeing the answer I don't remember that What would you suggest be the best use?
Thanks.
Sam
----
"No special sig just plain old Sam..."
|
|
|
|
|
From all the other source, mostly the source for the MD2 file format stores this type of information int an 'integer' variable.
Originally I would suggest you to use char array, but after having seen your answer to Michael, I couldn't imagine any other methods.
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
I don't get it. Why would you want to store a string in an integer? You could only store a pointer to character array, which would be meaningless when read back in?
What's wrong with a good old char[4]?
Michael
Communication is the first step towards enlightenment.
|
|
|
|
|
I don't know. I am writing a 3D application and have the file format. From all the other source, mostly the source for the MD2 file format stores this type of information int an 'integer' variable. I myself do not know why John C uses an int and not char[4] or char[5] if accomadating for the '\0'.
Sam
----
"No special sig just plain old Sam..."
|
|
|
|
|
It's highly dangerous to do this. You are relying on an int being 32 bits, which it isn't necessaryily. What if MS changed int to a 64bit in a future release? you're app would not load data correctly most probably.
Signature space for rent. Apply Within.
|
|
|
|
|
Actually this is a good point. Or, you can typedef or explicitly define an int being 32 bits. But this is something I think John C would have thought of I wonder why he used this as an ID value?!?! I'm puzzled.
Sam
----
"No special sig just plain old Sam..."
|
|
|
|
|
Hi,
I'm trying to add a new string value under an existing registry key. I see the APIs to delete , enum and set a value but I just can't figure out how to add a NEW string value under an EXISTing key.
Please help.
Thanks!
This is what i've tied but it creates a KEY and not a VALUE under "Info"
if(RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
"SOFTWARE\\BFW\\SampleTool\\Info",
0,
KEY_ALL_ACCESS,
&hkey
)==ERROR_SUCCESS)
{
if(RegSetValue(hkey,"Info",REG_SZ,"Test",5)==ERROR_SUCCESS)
I'd like to see Test appear as a REG_SZ under the Info Key.
|
|
|
|
|
|
RegSetValueEx(hkey,"Test",0,REG_SZ, NULL,NULL)
Did the trick.
Thanks.
|
|
|
|
|
Hi,
This will solve your problem.
unsigned long ValueSize = 10; // you can use also sizeof ( long ) or anything you need.
if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\BFW\\SampleTool\\Info , 0, KEY_READ|KEY_SET_VALUE, &hKey) != ERROR_SUCCESS )
{
// error message.
return;
}
RegSetValueEx(hKey,"Info",NULL,REG_SZ,(unsigned char*)5,ValueSize);
Aizik Yair
Software Engineer
|
|
|
|
|
I was wondering anyone can help me out on how best to design the following:
I have a piece of code which is HIGH PRIORITY. This must be ran at a set timing interval (say 20ms- or at least close to it). It will be doind data acquisition and then putting all this in a buffer.
The GUI end will update the screen and variables that the above code retrieves at another rate (say every 1 sec). This thread will read the buffer and then do calc and then maybe graph it.
Now, I was thinking that the first piece of coe should be in a HIGH Priority thread.
Originally, I was thinking that I do a timer that will read the Buffer and also update the screen. However, I was thinking that during the intervals, there may also be lots of idle time, which can be used. I want the program to also data acq and if there is nothing going on (no timer either) to check and read the buffer. I was thinking aboput using the onidle.
Is this the best way to do what I would like? I want to EVEN out the tasks and time spent in the GUI thread without doing it only when the timer is called at certain intervals. Is there an effective way to do this?
Thanks in advance.
|
|
|
|