|
Please post your code graph - all filters you are using and especially source filter.
|
|
|
|
|
Hi,
I want to create 4 dimensional array, in that first three dimenstional are fixed size and the final index will be on 0 to N-numbers.
For eg, double array[500][25][10][NOT FIXED].. So I cant create statically, because the index size are more. Also I have tried 4 dimenstional vector, but its giving 2 problem.
(i) I am storing 4th dimenstion size is more than vector[0][0][0].max_size()
(ii) Storing and Retrieving its more time in vector
So Please let me know, if any other solution to store large array which is 3 index is FIXED and final one is not FIXED?
Looking for answer from anyone..
Thanks.
|
|
|
|
|
|
The memory layout of a C array like char my_array[4][3][2] is the following (where a '0' character is a placeholder for 1 byte):
first dim=0 first dim=1 first dim=2 first dim=3
00 | 00 | 00 # 00 | 00 | 00 # 00 | 00 | 00 # 00 | 00 | 00
▲ ▲ ▲ ▲ ▲ ▲
| | | | | |
| | [0][2][1] | | [2][2][1]
| [0][1][0] | [2][1][0]
[0][0][0] [2][0][0]
Where '#' means a change in the first index and '|' is a change in the second index, while the 3rd index just moves 1 byte. Because of this memory layout you can make only the first dimension resizable if you are using a pointer instead of a fixed size static array. If you wanted to resize some other dimensions then you should insert bytes in many places but resizing the first dimension means just adding memory at the end of you currently allocated memory, or maybe shrinking the current storage. The above char my_array[4][3][2] could be allocated dynamically in the following way:
typedef char ArrayType[3][2];
ArrayType* p = new ArrayType[4];
p[3][2][1] = 0;
ArrayType* q = (ArrayType*)malloc(sizeof(ArrayType)*4);
q = (ArrayType*)realloc(q, sizeof(ArrayType)*5);
q[4][2][1] = 1;
Note that indexing into p and q are very fast like it is in case of static arrays and the occupied memory is 1 big chunk of continuous area. If you need just 1 resizable dimension then you can go with this technique because it really doesn't matter which dimension has this resizable trait. Lets say you make a 2 dimensional array because you want to store additional data to specific X and Y coordinates. If you need resizable 'Y' dimension then you address the array this way: [Y][X] but if you need resizable 'X' dimension then you simple index this way: [X][Y]. The same applies to multiple dimensions, it really doesn't matter which index do you use for different things, the only 2 things it can screw up is the memory layout of items (cache misses) and the readability of the source code - but sometimes you have to sacrifice readability if you are optimizing because this kind of thing is something that smells like optimization.
|
|
|
|
|
double array[500][25][10][<NOT FIXED>].
I am achieving this using vector(vector(vector(vector(double)))) dBuffer(....);
As of now I am using vector[500][25][10][UnknownSize].
UnknownSize will be decided on run time. I cant create the memory for final size. Because the final index value it will come splited way. For eg, one iteration it will come 100 values, after some iteration it will come 150 values.. For that I cant create the pointer to store for 100,150,etc... So i need use some STL..
Pls suggest me which STL is useful... Currently i am using 4D vector. But its execution time is more.
|
|
|
|
|
What do you want to achieve? There is no golden hammer that solves everything.
|
|
|
|
|
If your only problem would be an array with one dynamic dimension, you could try this:
std::vector<double> array[500][25][10];
That will create an array of 125000 double vectors of dynamic size. The statical allocation will not be a problem, and the time required for the dynamic allocation will be proportional to the actual number of elements. The only performance problem will be the deallocation - whenever that array runs out of scope, your program will take a considerable amount of time. With 125000 arrays, expect the deallocation to run for anything between a couple of seconds and a few minutes!
However:jothivel k wrote: (i) I am storing 4th dimenstion size is more than vector[0][0][0].max_size()
If I understand this comment correctly, you are trying to statically store data that exceed the address space of your application! If so, the answer is simple: you can't do that! What you need is a database! Try your luck with MySQL or google for another database library.
|
|
|
|
|
You could consider simply making the final index fixed at N.
Alternatively, don't even bother. The index is a fairly simple calculation, so simply allocate an array of the proper size and do the calculation yourself.
|
|
|
|
|
Dear sir,
I have given a doc of logon request which should be formatted like given below -
00 2E 60 01 23 06 00 08 00 20 20 01 00 00 c0 00 .5 .#.... .....
00 92 00 00 00 00 12 01 23 48 30 30 30 30 30 30 ........#H000009
39 53 31 30 30 30 30 30 30 30 30 30 30 30 30 35 9S10000000000005
when i extracted bit fields from bit map i got the fields 3,11,24,41,42 in which field 3 and 11 are in N6 format, field 24 is in N3 format and field 41,42 are in ANS format..
I have gone through many reference sites of iso 8583 message format but i did not how can send the data..
whether i should convert the fields which are in N6 to BCD.
whether i will have to send bit field as it is or i need to change it also in BCD..
How to send..pls help
|
|
|
|
|
There is only one reference page which is reliable when it is about ISO, and this is ISO.org.
Have a look at the standard as it is scripted there[^] and you will find the answer by yourself.
|
|
|
|
|
I have sent the packet through tcp socket. when i was analyzing the packet through wireshark i was getting the packet in the server side like below :
2E 60 01 23 06 08 20 20 01 c0 00 .5 .#.... .....
92 12 01 23 48 30 30 30 30 30 30 ...#H000009
39 53 31 30 30 30 30 30 30 30 30
30 30 30 30 35 9S10000000000005
while my actual packet is
00 2E 60 01 23 06 00 08 00 20 20 01 00 00 c0 00 .5 .#.... .....
00 92 00 00 00 00 12 01 23 48 30 30 30 30 30 30 ........#H000009
39 53 31 30 30 30 30 30 30 30 30 30 30 30 30 35 9S10000000000005
Why all 00 bytes are not getting sent..Can anybody tell me.
Please Help !!!!!
|
|
|
|
|
Once again, read the ISO standard carefully, it is explained nicely there.
And you might want to learn about sockets, or post the problem with the socket separately.
|
|
|
|
|
Message Closed
modified 25-Apr-13 3:33am.
|
|
|
|
|
Pleas edit this entry and remove the blockquote surrounding the code and replace with <pre> tags, so your code is readable.
Use the best guess
|
|
|
|
|
|
1. I guess you did not understand what "please edit the above entry" means.
2. Check what?
Use the best guess
|
|
|
|
|
Hello Sir,
I really did not understand what "please edit the above entry" means. Can you pls tell me..
Do I need to edit something in the code or is this not the write way to post the code?
Thanks
|
|
|
|
|
He kindly asked you to edit your existing post (there is a button to do so) and format the source code so that it is readable. To do so, select the code section and click the 'code' button above the editor window or place a <pre> tag at the begin of the code and a </pre> at the end (when clicking the 'code' button this is done automatically). In all cases, check the preview window below the editor window.
In the editor window it should look like this:
<pre lang="c++">
// A comment
#include <stdio.h>
int main()
{
return 0;
}</pre>
Then the preview (and the final post) will look like this:
#include <stdio.h>
int main()
{
return 0;
}
|
|
|
|
|
I am using the below code for packing the data in iso 8583 format
00 2E 60 01 23 06 00 08 00 20 20 01 00 00 c0 00
00 92 00 00 00 00 12 01 23 48 30 30 30 30 30 30
39 53 31 30 30 30 30 30 30 30 30 30 30 30 30 35
#include <WS2tcpip.h>
#include <stdio.h>
#include <stdlib.h>
#include <WinSock.h>
#include <wchar.h>
#include <string.h>
char cHexDigit_to_Nibble1(unsigned char c)
{
if(!isxdigit(c))
return (0);
if(isdigit(c))
return (c - '0');
c = toupper(c);
return (c - 55);
}
void vAscii2BCD(unsigned char *pucSrc, unsigned char *pucDst, int inSize)
{
for (; inSize > 0; inSize -= 2, pucDst++)
{
if(!memcmp(pucSrc, "3D", 2))
{
pucSrc += 2;
*pucDst = '=';
}
else
{
*pucDst = cHexDigit_to_Nibble1(*pucSrc++) << 4;
*pucDst |= cHexDigit_to_Nibble1(*pucSrc++);
}
}
printf("data is %s\n\n",pucDst);
}
int main()
{
int sock_desc, status;
struct sockaddr_in client;
struct addrinfo hints;
WSADATA Data;
int bytesSent;
int bytesRecv = SOCKET_ERROR;
unsigned char *pucSrc = (unsigned char*) malloc (100) ;
unsigned char *pucDst = (unsigned char*) malloc (256) ;
memset(pucSrc,0,256);
memset(pucDst,0,256);
vAscii2BCD((unsigned char*)"00" ,pucDst, 1) ;strcpy((char*)pucSrc,(char*)pucDst) ;
memset(pucDst,0,256);
vAscii2BCD((unsigned char*)"2E" ,pucDst, 1) ;strcat((char*)pucSrc,(char*)pucDst) ;
memset(pucDst,0,256);
vAscii2BCD((unsigned char*)"6001230600" ,pucDst, 5) ;strcat((char*)pucSrc,(char*)pucDst) ;
memset(pucDst,0,256);
vAscii2BCD((unsigned char*)"0800" ,pucDst, 2) ;strcat((char*)pucSrc,(char*)pucDst);
memset(pucDst,0,256);
vAscii2BCD((unsigned char*)"2020010000" ,pucDst, 5) ;
strcat((char*)pucSrc,(char*)pucDst);
memset(pucDst,0,256);
vAscii2BCD((unsigned char*)"C00000" ,pucDst, 3) ;
strcat((char*)pucSrc,(char*)pucDst);
memset(pucDst,0,256);
vAscii2BCD((unsigned char*)"920000" ,pucDst, 3) ;
strcat((char*)pucSrc,(char*)pucDst);
printf("size of pucSrc = %d\n", strlen((char*)pucSrc));
vAscii2BCD((unsigned char*) "0000" ,pucDst, 2) ;
strcat((char*)pucSrc,(char*)pucDst) ;
printf("size of pucSrc = %d\n", strlen((char*)pucSrc));
memset(pucDst,0,256);
vAscii2BCD((unsigned char*) "12" ,pucDst, 1) ;strcat((char*)pucSrc,(char*)pucDst) ;
memset(pucDst,0,256);
vAscii2BCD((unsigned char*)"0123" ,pucDst, 3) ;strcat((char*)pucSrc,(char*)pucDst) ;
strcat((char*)pucSrc,"H0000009S10000000000005");
printf("size of pucSrc = %d\n", strlen((char*)pucSrc));
status = WSAStartup(MAKEWORD(2, 2), &Data);
if(status != 0)
{
printf("ERROR: WSAStartup unsuccessful");
return 0;
}
else
{
printf("WSAStartup Successfull\n");
}
sock_desc = socket(AF_INET,SOCK_STREAM,0);
if ( sock_desc == INVALID_SOCKET ) {
printf( "Error at socket(): %ld\n", WSAGetLastError() );
WSACleanup();
return;
}
client.sin_family = AF_INET;
client.sin_addr.s_addr = inet_addr( "41.208.68.76" );
client.sin_port = htons( 4444 );
if(connect(sock_desc,(struct sockaddr*)&client,sizeof(client)) == SOCKET_ERROR) {
printf( "Failed to connect.\n" );
WSACleanup();
return;
} else{
printf("connect successfull\n");
}
bytesSent = send( sock_desc, pucSrc, strlen(pucSrc), 0 );
printf( "Bytes Sent: %ld\n", bytesSent );
while( bytesRecv == SOCKET_ERROR ) {
bytesRecv = recv( sock_desc, recvbuf, 256, 0 );
if ( bytesRecv == 0 || bytesRecv == WSAECONNRESET ) {
printf( "Connection Closed.\n");
break;
}
printf( "Bytes Recv: %ld\n", bytesRecv );
if (bytesRecv < 0)
return;
printf( "Bytes Recv: %ld\n", bytesRecv );
}
return 0;
}
when I was analyzing the packet through wireshark I was getting the packet in the server side like below :
2E 60 01 23 06 08 20 20 01 c0 00
92 12 01 23 48 30 30 30 30 30 30
39 53 31 30 30 30 30 30 30 30 30
30 30 30 30 35
Why all 00 bytes are not getting sent.
|
|
|
|
|
You are using string functions (strcpy() etc.) to copy your data (which are not strings) from one buffer to another, so each copy will stop as soon as it hits a zero character. Use memcpy() and ensure you copy the exact number of bytes that you wish to transfer.
Use the best guess
|
|
|
|
|
Hi All,
I have made an MCI player which plays ".wav" file well using MCISendString command.
Now I want my application to get number of headsets (audio output)devices attached. I want to play my wave file simultaneously in all the audio output devices.
Please help!
Thanks in advance
|
|
|
|
|
|
Hi i have developed an tool which writes data into the MS-Access file (Eg: empdata.mdb which exist in remote pc).
- Certainly this exe will run in many machine across network( Approxmatively 30 machines)
When i run the exe in diffrent machines (windows 7) it giving
the following error.
"It is already opened exclusively by another user , or u need permission to view its data."
Could anyone help in resolving the issues.
Thanks & Regards
Mani
|
|
|
|
|
The error message indicates that the database has been opened by another application with exclusive access or the user hasn't sufficient privileges to access the database file.
When using the CDaoDatabase class, pass FALSE as second parameter to the Open() function.
When using Access, it must be configured to open files in shared mode (this is the default).
The database file must be readable and writable for the users.
See also Ways to share an Access database[^].
|
|
|
|
|
Hi,
Is it 'thread safe' to use API'slike
::SetWinowText(...) and
::ShowWindow(hWnd,nCmdShow) across threads, or should I use e.g.
::SendMessage(hWnd,WM_SHOWWINDOW,fShow,bShow) I want to Hide and Show and set aspects of a Progress Dialog box during the run of the worker thread.
Regards,
Bram van Kampen
|
|
|
|
|