|
Ok I think I am getting the picture.
But I cannot figure out how to implement same pointer arithmetic in double array.
I got the first "record" working fine, can access all strings / fields, but cannot get to the next one.
I am still not sure how does the pointer , and not the char in array , get incremented.
I have deleted the LCD code which confused many and added printf , which is not part of "core" Arduino code , so this should pass by them now.
I still would like some verbal description of the assignment of pointer to the array.
Appreciate your help very much.
Cheers
Vaclav
<pre lang="c++"> // double array of pointers
char *stringTable[][5] = {{ "string 1", "string two", "string three", NULL },
{ "second string 1", "second string two", "second string three", NULL }
};
char **curPtr = *stringTable; // pointer to array of pointers
do
{
printf("%s\n", *curPtr++); // dereference to get the ptr to the string
} while ( *curPtr ); // quit loop when we get to our NULL pointer.<pre lang="c++"><pre lang="c++"></pre></pre></pre>
|
|
|
|
|
No problem, it's one of the problems that seems to beat-up people regularly. I more or less started with ASM, so it was a matter of sink or swim in short order.
How about this, does it help?
int main()
{
char *stringTable[][4] = {
{ "string 1", "string two", "string three", NULL },
{ "second string 1", "second string two", "second string three", NULL }
};
int y;
for (y=0; y<sizeof(stringTable)/sizeof(stringTable[0]); y++) {
char **curPtr = stringTable[y];
do
{
printf("%s\n", *curPtr++);
} while (*curPtr);
printf("----\n");
}
}
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
Thanks,
problem solved.
Actually while "programming in my sleep" I thought that I must be missing advancing the "main" pointer by the whole record. But stringTable[y] is nice "trick".
I really appreciate your help and as soon as I figure out how to add the characters into the record ( one at a time ) I'll be all set.
You have a great day.
Cheers
Vaclav
PS When I get ambitious I will try to figure out how to replace stringTable[y] using pointer.
|
|
|
|
|
Vaclav_Sal wrote: Problem #1 is probably how does the LCD class do the "print" and I can figure that one by myself. I do not expect this forum to be familiar with Arduino "library". I use a 4x20 LCD display on my Arduino Uno and Mega boards. What are you trying to do?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Try asking one question at a time. If I have to spend 30 minutes trying to figure out what you're really getting at, I'm not too inclined to help. Help us help you. Keep the questions straightforward.
Jeremy Falcon
|
|
|
|
|
I am not sure what the readers problems are - my English or their inability to read.
I do not like to engage in this kind of non technical discussions, have better things to do.
But since you asked
I said I can figure out the LCD "problem" - so I really don't understand why I am getting all the flack for mentioning it. I was trying to avoid " what are you trying to do?".
So again , I have NO Problem with LCD , it is just a convenient way to track my code.
And if it includes stuff you feel is weird so what. It has NOTHING to do with my MAIN question.
And the question is in the title of this post.
So far only ONE reply has given me REAL answer.
I have been around here for a while and in past EVERYBODY was 100% courteous and very helpful.
I am occasionally participating in Arduino forum where majority of "gurus" are nowhere near of caliber of knowledge as this forum is.
They commonly switch subject, give lectures on OT , hamper on "post you full code", "what you doing?" , scrutinize coding style (if it does not lineup with their style) etc. Very egotistical and unfriendly bunch, especially to beginners.
<b><b><b></b></b>I am rather sadden to see that similar attitude is showing up on this forum.</b>
I am sorry I got on my soap box, but if you have no idea you are doing / posting in style not in line with this forum traditions and guidelines you should be told so.
So that what I did.
Please no more off the tech subject stuff.
Cheers and have a nice one.
Vaclav
|
|
|
|
|
You have the wrong attitude.
Jeremy Falcon
|
|
|
|
|
Vaclav_Sal wrote: I am not sure what the readers problems are - my English or their inability to read. Neither, it's the fact that you question is rather over complicated, without actually explaining what the problem is. Hence my original reply to your question, which you ignored.
|
|
|
|
|
Hello everyone,
I have a weird situation...I have a CToolBar that has a parent of a CPagerCtrl which has a parent of a CDockingPane. Why I developed it that was is a long story and changing the architecture is not really an option at this point. Everything is working quite well except for one problem behavior. And this wouldn't have been a problem had the requirements not changed.
The problem behavior is that initially the toolbar has 9 buttons, but before it is shown I remove some of them depending on the options enabled. Depending on the state of the application at a particular time I may add buttons back. The toolbar does not reflect the change. In the past I would have just called RecalcLayout() on the frame window and voila, the toolbar would adjust it's size to properly reflect the new buttons.
I am at a loss on how to accomplish this with this architecture. I have tried many things...so many I can't remember them right now. Any ideas/help would be greatly appreciated. I will post any code upon request. I am just not sure what is of value right now.
Thanks,
Craig
|
|
|
|
|
I aim to build a network system like router or firewall based on customized embedded Linux. about the memory and stack, I will use embedded appliance like ARM boards or Atom not a simple Micro-controller or processor. which lang. you advice me to use C or C++? . I will use YOCTO Project to help me do that.
I built a similar network system.it was a network IDS but, it was based on xPC Target Kernel. Now, I wish to use an Embedded Linux. the system must do the basic task, so no many options. I have an experience in C and C++ but under DOS not Linux. C++ has the many options make the system design is easier but I fare the compatibility if I used it in embedded Linux. So any advice?
|
|
|
|
|
Abdullah A._Mohamed wrote: C++ has the many options make the system design is easier but I fare the compatibility if I used it in embedded Linux. So any advice?
I bet on C++ : Linux usually provides g++ that is a very good C++ compiler.
By the way, could you please delete your duplicate post?
|
|
|
|
|
CPallini wrote: By the way, could you please delete your duplicate post?
It's not just a duplicate post - he's created two accounts as well!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Wait, maybe we have a replicant! 
|
|
|
|
|
thank you Pallini, its not a duplicated but I am a new here and I login using my other accounts like face and g+ So, it seems two accounts is made and I put the Q on the two accounts. sorry.
modified 24-Jul-15 1:25am.
|
|
|
|
|
Oh, that is no problem at all, for me.
You are welcome. 
|
|
|
|
|
Abdullah A._Mohamed wrote: I fare the compatibility if I used it in embedded Linux
C++ is used pretty extensively in embedded Linux.
This is more of a matter of preference, you should be able to easily find supporting libraries for both, but I'd imagine that you'd find quite a bit more for C++... so that may be the easiest route.
|
|
|
|
|
Albert Holguin, thank you, I hope that.
|
|
|
|
|
See my response to Carlo's message below.
|
|
|
|
|
Don't know why someone downvoted this, have my upvote.
|
|
|
|
|
Thanks Carlo... probably somebody who doesn't know what they're talking about. I'm actually right in the middle of implementing a bunch of C++ on an ARM processor. Cross-compiling is your friend. 
|
|
|
|
|
I aim to build a network system like router or firewall based on customized embedded Linux. about the memory and stack, I will use embedded appliance like ARM boards or Atom not a simple Micro-controller or processor. which lang. you advice me to use C or C++? . I will use YOCTO Project to help me do that, so any advice?
I built a similar network system.it was a network IDS but, it was based on xPC Target Kernel. Now, I wish to use an Embedded Linux. the system must do the basic task, so no many options. I have an experience in C and C++ but under DOS not Linux. C++ has the many options make the system design is easier but I fare the compatibility if I used it in embedded Linux. So any advice?
|
|
|
|
|
If it's embedded, go with C. Otherwise, just pick whichever one you want.
Jeremy Falcon
|
|
|
|
|
As the title states, I am having problems reading uncompressed avi files in MFC. It works fine on some files and reads different data on some avi files.
Here is the code-
pStream = g_GetAviStream(_T("D:\\Lab_Programs\\Matlab\\output.avi"), &frames, &fWidth, &fHeight, &iFirstFrame, &nPlanes, &fBufSize);
fWidthOffs = fWidth%4;
tempBuff = new BYTE[fWidth*fHeight*nPlanes];
ZeroMemory(tempBuff, sizeof(BYTE)*fWidth*fHeight*nPlanes);
pFrame = AVIStreamGetFrameOpen(pStream, NULL);
bytBuff = new BYTE[fBufSize];
for (i = 0; i < frames; i ++)
{
imgTemp = (BYTE*) AVIStreamGetFrame(pFrame, i);
RtlMoveMemory(&bih.biSize, imgTemp, sizeof(BITMAPINFOHEADER));
RtlMoveMemory(bytBuff, imgTemp+sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)*256, bih.biSizeImage);
ind = i*fWidth*fHeight*nPlanes;
for (j = 0; j < fHeight; j ++) {
idxd1 = j*nStimVideoNX;
idxs = (fHeight-1-j) * (fWidth * nPlanes + fWidthOffs);
for (k = 0; k < fWidth; k ++) {
datain = bytBuff[idxs + k*nPlanes];
tempBuff[idxd1+k] = datain;
}
}
}
After doing this, I am writing tempBuff to a text file to view the contents in maltab and imshow it. If you play the video, you will see two black squares inside the frame, but when I check the text file for frame 3, I only see one black square. Here is the link[^] for a sample file that I am trying to read.
PKNT
|
|
|
|
|
Are you certain that all of your test files have a 256-colour palette? See the BITMAPINFOHEADER structure[^] for details about other possibilities.
Note also that the height, width, and number of planes are encoded in the header. Ensure that these are as expected before decoding!
Lastly, the BITMAPINFOHEADER contains its size in the first element. Use this either as a "sanity check" or instead of sizeof(BITMAPINFOHEADER).
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
For the file I attached in my first post, AVIFileInfo is returning the following data-
avi_info {dwMaxBytesPerSec=0 dwFlags=0 dwCaps=3 ...} _AVIFILEINFOA
dwMaxBytesPerSec 0 unsigned long
dwFlags 0 unsigned long
dwCaps 3 unsigned long
dwStreams 1 unsigned long
dwSuggestedBufferSize 2296 unsigned long
dwWidth 26 unsigned long
dwHeight 82 unsigned long
dwScale 33333 unsigned long
dwRate 1000000 unsigned long
dwLength 30 unsigned long
dwEditCount 0 unsigned long
szFileType 0x0068e930 "AVI Default File Handler" char [64]
When I write the frame to a text file after
imgTemp = (BYTE*) AVIStreamGetFrame(pFrame, i);
I see the correct header of 1064 bytes, but the image data doesn't have two black squares that I am supposed to see (for example from frame 3), but only one black square.
Any ideas?
PKNT
|
|
|
|
|