Click here to Skip to main content
15,217,185 members

Comments by Frankie-C (Top 200 by date)

Frankie-C 22-Feb-16 6:01am View
   
Read the remark section in https://msdn.microsoft.com/en-us/library/windows/desktop/ms646291(v=vs.85).aspx. All child window are part of a top window enable/disable chain, but with a lot of details as usual in Win.
Frankie-C 22-Feb-16 5:38am View
   
there are many tricky things related to the window state, the calling thread etc.
Have you tried using SetForegroundWindow()?
Frankie-C 20-Feb-16 13:50pm View
   
You cannot set focus on a disabled window. Enable window then set focus.
Frankie-C 1-Jan-16 12:11pm View
   
Try using mapping views of file like mmap( ).
Frankie-C 12-Dec-15 14:27pm View
   
I don't see the initialization of 'foundNTDLL' using 'GetProcAddress(hdlNtCreateFile, "NtCreateFile");'.
You omitted it for simplicity or you never initialized it?
Frankie-C 16-Oct-15 8:13am View
   
Jochen you're right. From C11 standard - 6.7.2.1 Structure and union specifiers:
"An implementation may allocate any addressable storage unit large enough to hold a bitfield.
If enough space remains, a bit-field that immediately follows another bit-field in a
structure shall be packed into adjacent bits of the same unit. If insufficient space remains,
whether a bit-field that does not fit is put into the next unit or overlaps adjacent units is
implementation-defined. The order of allocation of bit-fields within a unit (high-order to
low-order or low-order to high-order) is implementation-defined. The alignment of the
addressable storage unit is unspecified."

So bitfields of same type will be packed together.
I can add that because this is often used for packing hardware registers fields in structures, it is very unlikely that it will change, or a lot of OS and driver code will need fixes...

P.S. the order of allocation is generally the same of processor endianess. On X86 (little endian) runs from low to high order.
Frankie-C 3-Sep-15 14:27pm View
   
See my update to the answer.
Frankie-C 2-Sep-15 13:17pm View
   
Thanks Sergey
Frankie-C 1-Sep-15 6:19am View
   
If you got this:
`WndProc : ffff12b3`
Means that the procedure address is invalid. It has been changed somewhere...
Frankie-C 14-Aug-15 6:46am View
   
try this http://www.codeproject.com/Articles/32925/Scrollable-Dialog-in-Pure-Win-API.
Read https://msdn.microsoft.com/en-us/library/ms997557.aspx and http://www.functionx.com/win32/controls/scrollbars.htm
Frankie-C 6-Aug-15 15:15pm View
   
Which code? there is nothing.
BTW we cannot understand what happen if you don't show us some code of your exe's.
What is xx.dat file, who create it, where is it created?
Frankie-C 3-Aug-15 7:43am View
   
5ed. Side effects have to be avoided...
Frankie-C 24-Jul-15 11:07am View
   
Yes, you're right again. The ms standard is the most used because at least two compilers use it: MSVC++ and DigitalMarsC++ :(.
This paper http://www.agner.org/optimize/calling_conventions.pdf from Agner Fog give it's almost exhaustive on the issue.
Frankie-C 24-Jul-15 3:28am View
   
Thanks Albert.
You're absolutely right, the MS mangling method is almost a de-facto standard, but not a standard anyway. Other compilers can implement different mangling, and in any case it is never a good practice to implement mangled names in exported symbols.
Frankie-C 23-Jul-15 13:09pm View
   
thanks
Frankie-C 22-Jul-15 7:34am View
   
This is a complicate code for a first attempt to get a client/server working code.
IMO the problem is in the use of select after a connection is estabilished, it is powerful, but not handy. I suggest you to start to read incoming data without the select (this will be a blocking call because I think to have not seen a setting for not blocking).
If you need to handle more than one connection at time I suggest to use threading (also your code using select will not work anyway).
For a sample please look from my answer here: http://www.codeproject.com/Answers/987749/Is-it-possible-to-run-client-server-communication?arn=0#answer3
Frankie-C 22-Jul-15 5:45am View
   
This is a good reason to start to learn ;-)
Moreover even without debugger you need to learn better how to implement program flows and function calls works.
Generally when a function is called you come back before to recall that function again, if you call it inside itself this is called recursion, and in this case you must check that the whole calling flow will stop after a while, or you'll fill the stack with return addresses up to overflow.
But you made something even worst: you have a couple of functions that call each other (GetChoice and Decider) without any control. The program workflow is inexistent and you continue to go in one function than inside the other without ever return...
Frankie-C 22-Jul-15 5:25am View
   
Yo're welcome I'll be glad to hear if you solved your problem.
Frankie-C 22-Jul-15 4:02am View
   
Wireshark installs a driver that intercepts whole network traffic and for any address that can be seen from the connection (sniffing). The Driver is a complete package available in open source named 'WinPcap" (google for it). This is *not* the solution for your problems anyway.
The problems you have IMHO are not related to receive routines nor to the threads priorities. Maybe there are problems with buffer dimensions (ReceiveFrom() discards data if buffer is not sufficient to hold whole received data).
Frankie-C 20-Jul-15 4:16am View
   
You're welcome.
Frankie-C 19-Jul-15 6:31am View
   
You're welcome.
If the solution worked please accept it so we can close the question as solved.
For the background colour you cannot set it in the MDI client window, but you have to set it in any window intercepting the messages WM_ERASEBKGND.
See https://social.msdn.microsoft.com/Forums/vstudio/en-US/f5aecf40-1f22-400d-85d2-db601ec8d71b/changing-background-color-by-using-button-win32-api?forum=vcgeneral
Frankie-C 19-Jul-15 6:15am View
   
Thanks
Frankie-C 18-Jul-15 16:53pm View
   
5'd
Simple functions to set or reset the Nth bit are based on this concept.

unsigned SetNthBit(unsigned val, unsigned cBitN)
{
return val | (1 << cBitN);
}


unsigned ResetNthBit(unsigned val, unsigned cBitN)
{
return val & ~(1 << cBitN);
}
Frankie-C 17-Jul-15 9:45am View
   
Yes :), but only because the compiler by itself does the following:
1. Allocate 4 monodimensional char arrays and initialize them with the strings
2. Allocate an array of pointers and init it with the address of the 4 strings.
But it is *not* as a two dimensional array of chars, which layout in memory is the first array of chars, then the second, the third and the last one. And in the case of multidimensional arrays it is required that each array has the same dimension.
So if you have:
char *arr[4];
The memory layout is:
0023000 00231000 //address of string 1
0023004 00232000 //address of string 2
0023008 00450020 //address of string 3
002300c 00221344 //address of string 4

If you declare:
char arr[4][4] = {{'h', 'e', 'i', '\0'}, {'h', 'e', 'l', '\0'},{'h', 'a', 'i', '\0'},{'h', 'o', 'i', '\0'}};
and inspect the address of arr you'll find:
0023000 68 65 69 00 68 65 6c 00 68 61 69 00 68 6f 69 --- hei.hel.hai.hoi.
This is a C multidimensional array.
Frankie-C 17-Jul-15 8:05am View
   
Thanks for the info, but after 30 years of programming and compiler construction technology I know something different.
You may want give a check to memory allocation using a debugger.
Frankie-C 17-Jul-15 7:04am View
   
+5!
One is an array of 4 pointers to char, the other is a char array.
Multidimensional arrays have nothing to do with this case.
Frankie-C 11-Jul-15 15:13pm View
   
Cannot read the whole code, but the problem seems in the default precision that's why I suggested to specify a large precision to have more digits.
Evidently the CygWin version manages better the default precision, or the runtime holding the double to ascii conversion have a different default precision.
Anyway godd to hear that you solved the problem. ;-)
Frankie-C 11-Jul-15 11:20am View
   
Yes, you're right, but, as stated also in the link provided, is not completely exact. An array name is equivalent to the address of the first element of the array, so it's a pointer to the element type. This small difference makes the trick when assigning values.
I.e. in the examples in my answer if you replace:
ptr1 = &arr;
with:
ptr1 = arr;
You will get an error from compiler, at least if it is ANSI compliant, like this:
error #2168: Operands of '=' have incompatible types 'int (*)[5]' and 'int *'
You can solve it with a cast:
(int *)ptr1 = arr;
But it's much more elegant, and correct, to use the right form.
Frankie-C 11-Jul-15 10:34am View
   
What means "Something unwanted happens inside the function LogData_thr" ?
What happens when you call it the second time?
Can you show us part of the LogData_thr code?
Frankie-C 8-Jul-15 3:20am View
   
We understood you, and I gave you the theory of how you should write in a window, and it works be sure about it.
So:
1. Make a simple program and check functionality of sample code, get familiar with it. If it don't work check your project, compiler and linker because there should be a problem somewhere.
2. Now use you creativity and wrote you code to obtain the goal.

In your case it could be:
LPTSTR SzToPrint[1024]; //a global variable holding the text to write

//PhysicalPrint physically prints to the window screen, called from WM_PAINT
void PhysicalPrint(HWND hwnd, HDC dc)
{
//Same as in the example, but instead of "Hello" prints the contents of SzToPrint
}

//Called by user to set what to print
void PrintMessage(HWND hwnd, LPTSTR szMsg)
{
_tcscpy_s(SzToPrint, 1024, szMsg);
UpdateWindow(hwnd);
}

Now put something from you...
Frankie-C 5-Jul-15 16:12pm View
   
The sample works. What means no result? You didn't got the text on the window?
This is the way it have to be done, there no other *simpler* ways.
Frankie-C 5-Jul-15 7:08am View
   
Really strange, anyway looking again the disassemblies you have write in the question there a re 16 bytes missing in the Delphi one, the C procedure seems 16 bytes longer, and this make no sense. You may want to check again the delphi disassembly.
If the Delphi code is scrambled you should see a call somewhere in delphi source, or in DllMain, else there is a little stupid error you are doing in dynamically linking the procedure.
Frankie-C 4-Jul-15 17:53pm View
   
The assembler code you reported has a lot of errors, I don't know if the disassembler has problems or you made some transcription errors (if you manually wrote it).
But I can't see any reason for different dissassembly (the opcodes are absolutely different). And the C disassembly make much more sense than the Delphi one...
Try to create a disassembly of the whole dll using dumpbin with switch /DISASM. Redirect the output to a file.
Frankie-C 4-Jul-15 17:12pm View
   
Ok the debugger got an exception and passed it back to sw for handling, but it should say also what kind of exception is.

The sequence:
xor eax,eax
push ebp
push xxxxxxxxh //some exception handling address
push dword ptr fs:[eax]
mov dword ptr fs:[eax],esp

is used to set the structured exception handling (SEH), and the register fs points to the current TIB (at fs:[0] there is a pointer to an EXCEPTION_REGISTRATION structure). For more info see http://reverseengineering.stackexchange.com/questions/2895/delphi-pascal-try-except-finally-block.
But from your report it seems that you are looking to two completely different functions... :-( Are there multiple functions with similiar names in your DLL?
Frankie-C 4-Jul-15 15:47pm View
   
I forget to add that you can't use the voip connection to send anything else.
If you want exchange also text you have to open a new connection *using a new socket* and manage the data exchange on yourself.
Or write your own software to manage a voip+text connection. In this case it will be your duty to create a way to mark voice and text data in the indistinct stream of bytes flowing along the connection on both sides.
Frankie-C 4-Jul-15 15:41pm View
   
I added the due explanation in the solution.
Each connection is generated and managed by its software. If the managing software is unaware of extraneous packets the connection broke.
Frankie-C 4-Jul-15 15:35pm View
   
Is this an homework?
Frankie-C 4-Jul-15 9:33am View
   
The CPU used by your app may be used by another thread created inside the call that runs for a while before to die, or could be the OS housekeeping on memory in case of memory access exception. The debugger should tell you when the app under test is creating another thread.
What you mean for 'first chance exception'?
No doubt on the PAnsiChar, it is the C null terminated string, so it is correct. But looking to Delphi code I'm not sure that you're passing an ANSI string, maybe the problem is that it wants a widechar string, you could check. In this case the typedef should be:
typedef char DLL_IMPORT DCLINITIALIZE(char bDeviceId, wchar_t *pStr);
About the runtime don't know what to tell, eventually you can have a look at libraries loaded in Delphi...
This DLL is publicy available?
Frankie-C 4-Jul-15 9:18am View
   
Thanks. You're right, there is a lot to say, but when I understood that he was using one of the obscure features of C I decided to comment that part, to make clear to novices that side and to explain that generally there is always another more correct way to do it ;)
At the end if you think about the whole issue it appears as an effort to complicate a simple matter. He just need a multidimensional array of pointers to char, a dimension for each language, and a single enum for languages, having also the benefit of direct access.
Frankie-C 3-Jul-15 5:31am View
   
Sure the library name is undecorated. I refer to the decoration problem on C compiler side (and this could be correct using the 'extern C'). But I forget that even C will look for the decorated symbol DCL_Initialize@8 that doesn't exist in your library. What I don't understand is if you created an import library from the DLL or not. If you don't you'll never find aliased symbols.
Anyway using the GetProcedureAddress should solve the problem.
The not return problem can be related to parameters, as far as I know in C and Delphi they are pushed onto the stack in the same order (reversed respect as they are declared), but just to check you can try to reverse them in the function declaration.
Frankie-C 3-Jul-15 5:20am View
   
So this is before entering the DLL code.
What you should do to check for wrong calling convention is to find the return instruction and check if the function returns to a wrong address. If so there could be wrong calling convention or stack corruption. For the __stdcall convention you must encounter something as:
. mov esp,ebp
. pop ebp
. ret 8 //__stdcall cleans stack on return
Now you have 2 cases:
1. Your software never reaches the return -> wrong parameters, missing Delphi runtime or the like
2. After ret instruction you don't return to the calling point: wrong calling convention, stack corruption or wrong parammeters.
The program simply hung-up or you get an exception?
Frankie-C 2-Jul-15 12:22pm View
   
Are you using C or C++? If you're using C++ the problem could be the decorations.
Try to include the declaration between 'extern C' See updated answer.
Frankie-C 2-Jul-15 12:20pm View
   
The instruction 'call eax' is inside the function DCL_Initialize?
Frankie-C 2-Jul-15 12:18pm View
   
My wrong. I've not seen.
Frankie-C 2-Jul-15 12:17pm View
   
The name of the function then is 'DCL_Initialize' because you got it with podump.
The __imp_DCL_Initialize should exist because it is automatically created from the linker when builds the jump table.
The #pragma comment tells to the linker to include the import library DCL.lib, not to change symbol. You can remove it and add DCL.lib to the linker input files list.
Frankie-C 28-Jun-15 8:39am View
   
1. Read a lot, be open mind, logic is philosophy. Don't believe your eyes, but your mind, or at least just believe on what is valid for both. (Yes follow also your heart, but we are talking of programming...)

2. Everybody are good to criticize and modify pre-existent work. But when you have nothing but the customer request and need to start from scratch, and there is no previous art nor experience, then ... you need creativity! Collect data and requirements, analyze, create, deploy.

3. Be eclectic as opposed to rigid. Don't keep stocked to common ideas or experience, but be open to explore new methods and new approaches without any preclusion. Read this for a better explanation https://en.wikipedia.org/wiki/Eclecticism
Frankie-C 27-Jun-15 8:17am View
   
5ed.
Numbers could be represented as a polynomial of powers of the base.
I.e. 13 = 1x10^1 + 3x10^0
When the base is 2 as in binary representation by shifting 1 is as moving a coefficient=1 to the polynomial value equal to the exponent.
So 1<<a is equivalent to 1x2^a
Frankie-C 24-Jun-15 3:16am View
   
I'm happy to have been of help, but please remove the comment you posted as a solution.
Frankie-C 22-Jun-15 12:49pm View
   
You're both right. It basically depends on what you have to synchronize.
Let's look at aspects of basic execution units, anything that is executing concurrently is a thread (you can dynamically break a thread in subthreads called fibres, but they acts as threads again). The process is only the environment in which a thread executes. we say each process has a private, isolated environment, but in machine terms it is only a different configuration of same resource, memory, through the use of MMU.
At task manager level each thread switching imply switching of its context too, that really means the process.
Anyway in a bunch of running threads each resource or even, and you have not considered it, shared interprocess memory can be a resource concurrently accessed by threads intra or inter process.
In plain words that's why exists so many event and sync objects that works between process.
Frankie-C 21-Jun-15 10:05am View
   
I think that we have not understood what you're asking.
They already explained you that the function 'strlen()' don't work for what you are doing. Its name is the contraction for 'string+length', and its scope is to find the length of a string of characters, not how many values you have put into a generic array.
When you declare an array it is instanced with the number of elements that you asked for in the declaration, in you case 100 integers.
Your code is not working:
1. Where is defined the variable i ?
2. In the do-while loop you write the result always in b[i] (and i is undefined).
3. In C arrays are zero based, meaning that they starts from 0. For an array of 100 elements the correct indexes are in the range 0-99 included. b[100] is an error!
4. From what we see (points 1,2 & 3) b[100] will never get any value
Please improve your question and your code if you want an answer.
Frankie-C 20-Jun-15 18:31pm View
   
Ok makes some sense now.
I updated the answer.
Frankie-C 20-Jun-15 17:06pm View
   
It's an homework...
Frankie-C 20-Jun-15 14:52pm View
   
Yes sometimes they are written in 'C', but this doesn't mean that an assembler transforms an assembler source in 'C'. Often (or always) a 'C' compiler transforms 'C' code to assembler :)
The assembler get a symbolic description of instruction and implements it in machine code. If in assembler you reserve a memory operand then use it the assembler does:
1. Remember the address where your variable should be and associate it to variable name.
2. When found the operation that uses the variable address put the machine code for the operation replacing the address with the one saved before.
The machine code emitted is appropriate to handle the operand size (BYTE, WORD, DWORD, etc..)
Frankie-C 20-Jun-15 13:43pm View
   
Have you tried to google "Open Source HTML report generator" ?
Frankie-C 20-Jun-15 13:18pm View
   
Assembler use also DWORDs, QWORDs, etc.
But the point is another: what is the sense of checking something declared in 'C'?
In you sample you declared a variable of type 'int' which size, in 'C', is 4 bytes, so you will always get 4.
If your question is how can detect dimension of variables declared in an assembly module using another language, the answer is: you can't.
If the module is compiled there is no way to get this information, if you have sources you have to declare manually that variable with correct type in the other language.
If you want to check if a value fits in a type Carlo gave you an example of how you can do.
Frankie-C 18-Jun-15 10:52am View
   
Thanks
Frankie-C 17-Jun-15 5:04am View
   
As they told you the problem is the scoping of your variable.
If you want understand something more about scoping see my answer:
http://www.codeproject.com/Answers/1000626/doubt-in-usage-of-extern-keyword-in-c-any-one-help#answer2
Frankie-C 15-Jun-15 4:57am View
   
This is not a solution! Pleas remove it.
If you want to replay to Richard click the button 'Replay' inside his comment and put your replay there. I this way he will also be informed of your replay.
Frankie-C 13-Jun-15 13:16pm View
   
More or less.
You still consider only 2 actions toward a variable: declaration and initialization. But they are 3: declaration, initialization and instantiate.
When you declare a variable you tell to the compiler that exists a variable of that type with that properties, the initialization allows you to assign an initial value to the variable. The compiler can decide to instantiate a variable (effectively create it) depending on the declaration.
Declaring a variable as extern doesn't instruct the compiler to *create* the variable. It can only get some information without creating any instance of the variable.
But when you make a declaration having an initialization you are telling to the compiler to *create* the variable, but it cannot because the position is wrong. That is the reason of the error.
Now if the answer satisfy you accept it, else I really don't know how to explain better.
Frankie-C 13-Jun-15 10:53am View
   
I explained in the updated answer.
The fact that the compiler doesn't give you an error when you don't try to initialize the variable doesn't mean that *you are allowed to use extern in a function body*!
Frankie-C 10-Jun-15 2:55am View
   
Sorry I don't know.
You have to debug it
Frankie-C 9-Jun-15 8:53am View
   
#ifndef PATH_MAX
#define PATH_MAX 4096 /* # chars in a path name including nul */
#endif

void CleanInput(char *p)
{
int i;
for (i = 0; i < PATH_MAX; i++)
{
if (!p[i] || p[i] == '\n')
{
p[i] = '\0';
break;
}
}
}

int receive_text(int new_socket)
{
long int buffersize = 0, recv_size = 0, size = 0, read_size, write_size;
int errno;
FILE *text;
char *pBuf, *filename;
char a[50];
char Fullfilename[PATH_MAX];
FILE *fp;
printf("Enter Filename: %s \n", filename);
fgets(filename, PATH_MAX, fp); //Read filename from user
CleanInput(filename); //Remove \n and close string

//Build a full filename with path

char Filename[PATH_MAX];
strcpy(filename, "/home/sosdt009/Desktop/received.txt,r");
strcat(Fullfilename, Filename);

//Open file with fully qualified name and read the first line

fp = fopen(Fullfilename, "r");
char filename2[PATH_MAX];
fgets(filename2, PATH_MAX - 1, fp);
fclose(fp);
CleanInput(Filename); //Remove \n and close string

//Print filename2, then open and read file2

printf("Filename2: %s \n", filename2);
fgets(filename2, PATH_MAX - 1, fp);
CleanInput(Filename); //Remove \n and close string
text = fopen(filename2, "w");
if (text == NULL)
{
puts("Error has occurred. Text file could not be opened \n");
fgets(filename2, PATH_MAX - 1, fp);
return -1;
}

//Loop while we have not received the entire file yet

while (1)
{

ioctl(new_socket, FIONREAD, &buffersize); //We check to see if there is data to be read from the socket
printf("Buffersize ioctl value is: %ld \n", buffersize);
fgets(filename, PATH_MAX, fp);
if (buffersize > 0)
{
printf("Buffersize value is: %ld \n", buffersize);
fgets(filename, PATH_MAX, fp);
pBuf = malloc(buffersize);
if (!pBuf)
{
fprintf(stderr, "Memory Error. Cannot allocate!\n");
fgets(filename, PATH_MAX, fp);
exit(-1);
}
read_size = recv(new_socket, pBuf, buffersize, 0);
printf("Read size value is: %li \n", read_size);
fgets(filename, PATH_MAX, fp);
if (read_size < 1)
{
printf("%s", strerror(errno));
fgets(filename, PATH_MAX, fp);
goto free;
}

//Write the currently read data into our text file

write_size = fwrite(pBuf, 1, read_size, text);
free(pBuf);
printf("Writesize value is: %li \n", write_size);
fgets(filename, PATH_MAX, fp);

//Increment the total number of bytes read

recv_size += read_size;
printf("Receivedsize value is: %li \n", recv_size);
fgets(filename, PATH_MAX, fp);
}
if ((buffersize == 0) && (recv_size != 0))
{
goto free;
}
}
free:

close(new_socket);
fclose(text);
printf("Text successfully received: \n");
getchar();
return 0;

}
Frankie-C 9-Jun-15 8:22am View
   
What a fantasy! What was supposed to do this piece of code?
char MAX_PATH;
for(i=0;i<=(MAX_PATH);i++)

The correct code is the following:
void CleanInput(char *p)
{
int i;
for (i = 0; i < PATH_MAX; i++)
{
if (!p[i] || p[i] == '\n')
{
p[i] = '\0';
break;
}
}
}
Frankie-C 9-Jun-15 5:27am View
   
A file path is a string, and you can assign to whatever is a character array. The problem is that the compiler refuses to init a char array with a string constant. Modify this way:

//Build a full filename with path
char Filename[PATH_MAX];
strcpy(filename, "/home/sosdt009/Desktop");
strcat( Fullfilename,Filename);
Frankie-C 9-Jun-15 3:02am View
   
MAX_PATH is not PATH_MAX
Frankie-C 9-Jun-15 2:58am View
   
use:
char Filename[PATH_MAX] = "/home/sosdt009/Desktop";
Frankie-C 9-Jun-15 2:55am View
   
Unfortunately I don't have a workaround right now.
I used last version for tests, and it behaves exactly the same.
Frankie-C 8-Jun-15 11:13am View
   
Great! As told behavior is compiler dependent.
Now you have compilation you like, but remember that the code is not portable, if you compile your code with another compiler you will get different result (unless you use the general rules).
Frankie-C 8-Jun-15 9:11am View
   
My first expectation was the same as you, but unfortunately we have not considered that the compiler cannot emit a continuous stream of bits strictly chained each other, so it uses the bit-field type change to break between storage parts. In fact the type of bit-field is used to define the size of container storage, and as per ANSI standard the bit-field cannot exceed the size of the type.
The same standards (C99, C11, C++11) says that the way the data is layed up in memory is compiler dependent, so we cannot force the compiler behavior to what is correct for us.
I have also noticed that you have already set packing to 1 because you got a result of 3 bytes, without it the space used is 4 bytes (for reason of bus access on odd addresses). Anyway the packing acts only on alignement between structure fields not on bit fields.
I started programming on DEC machines and have used structures to define hardware registers (where group of bits in the same register word had specific meanings) and had never had this problem. But I used always the same type for bit-fields, that solve your problem also.
I made some checks on different compilers, and the result is more or less the same: if you change the type it moves to next storage byte (some compiler doesn't even accept shorts and chars as types, but strictly adhere to ANSI standard that provides for signed and unsigned integers).
I'm sorry, but there is no other workaround for MSVC that using the same type for bit-fields that have to be in the same storage area. But what is your problem anyway? A char is a signed integer max size = 8bits and short is a signed integer too, but 16 bits max size. Declaring both as short works well afterall...

P.S. Reading again your answer I would advice you: have you noticed that you are not using same data type in bit-field (a char and a short)!
Frankie-C 8-Jun-15 7:35am View
   
I don't remember the code.
Something like this:
char FullPath[PATH_MAX] = "/home/sosdt009/Desktop/";
char filename2[PATH_MAX];
printf("Enter Filename:\n");
scanf("%s%*c", FullPath+strlen(FullPath));
FILE *fp = fopen(FullPath, "r");
fgets(filename2, PATH_MAX, fp);
int i;
for (int i=0; filename2[i]; i++)
if (filename2[i] == '\n')
{
filename2[i] = '\0';
break;
}
printf("Filename2: %s \n", filename2);
getchar();
FILE *text = fopen(filename2, "w");
Frankie-C 8-Jun-15 6:38am View
   
Under linux use PATH_MAX instead of MAX_PATH.
In the for loop I thing that is missing the ++ after the i:
for (i=0; some condition; i++)
Frankie-C 8-Jun-15 6:29am View
   
I already explained above that while the symbol _WIN32 is automatically defined by the compiler the values of _WIN32_WINNT and WINVER are not.
You have to manually set them (please see https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745%28v=vs.85%29.aspx#setting_winver_or__win32_winnt).
Read carefully the links provided.
Frankie-C 7-Jun-15 6:29am View
   
5ed!
Frankie-C 3-Jun-15 10:31am View
   
And maybe he also... :-D
Frankie-C 3-Jun-15 5:56am View
   
This is not the right way to answer. Be polite please.
Frankie-C 3-Jun-15 5:43am View
   
If you choose to use registry you can get advantage of binary keys and store there you're crypted data. The registry access is generally even more discouraging for unexpert users (for hackers ax Xor crypting is not such complex protection...)
Frankie-C 3-Jun-15 5:32am View
   
Yess of course a typo...
Frankie-C 3-Jun-15 5:26am View
   
Carlo I think that ini files cannot store the binary data that will come out from XOR crypting.
In my opinion him cannot use ini files (that are text files) to do what he wants unless the crypted data is not ASCII coded (i.e. using their hex representation).
A much better option would be to use registry...
Frankie-C 2-Jun-15 5:53am View
   
to avoid confusion to the beginner would be better to use the correct terms:
The AND operator performs a logical AND operation between each couple of bits occupying the same position in the two operands and producing the result in the same bit position in the result. I.e. 010101 AND 101100 = 000100.
The AND operation is *not* a comparison.
It is sometimes called *masking* operation because, due to the AND operation nature, you can craft a *mask* where all bits set to 1 are reported on ther esult, while bits set to 0 are masked to 0. I.e. 01010101 AND 11110000 = 01010000 => the first upper 4 bits are reported as they are because the mask have that bits set, while the lower 4 bits are set to 0 because the mask have that bits to 0.
Frankie-C 1-Jun-15 6:22am View
   
+5
Frankie-C 1-Jun-15 6:15am View
   
:-)
Frankie-C 29-May-15 8:05am View
   
I'm the one who fixed the title that was was somethinng as "I convert avi to bitmap".
Then he says he want convert video to bitmap, *then assemble the frames to one bitmap*.
That's not clear form me ;-)
Frankie-C 29-May-15 7:15am View
   
Can you explain better what you want to do?
Frankie-C 27-May-15 10:50am View
   
You're welcome.
Sorry to be unable to give you a complete solution.
Frankie-C 27-May-15 10:19am View
   
Using setsize what happened?
Have you considered the resolution of the tablet screen when setting the desired dimensions?
Frankie-C 27-May-15 10:12am View
   
Using a mobile internet connection make almost impossible the connection due to very volatile assignement of IP address in mobile subnets.
The only and old good solution is to use a relay server with known IP address and relays between users.
Difficult to add more, you can google for "tcp connection between to mobile devices" and will see many answers like mine...
Frankie-C 27-May-15 9:10am View
   
Thanks, but I told you to make also settings on the router to move messages coming from public address to the local computer. Have you done it? This link will give you some hints http://www.wikihow.com/Set-Up-Port-Forwarding-on-a-Router
Remember that the address to use is the *public address* not the local address. Because it changes on each connection (unless your provider assigned you a static IP address) you can use one of the many dymanic IP DNS (see https://www.google.com/search?q=dynamic%20ip%20dns&rct=j).
Frankie-C 27-May-15 7:01am View
   
I have updated solution using a simple fopen to check for file existence.
Please read the note: if you are trying to remove current executable it will *not* work because the file of a runnning task is locked by the OS.
Frankie-C 27-May-15 6:09am View
   
What means? Removing the return 0, now the program enters the if-else?
Frankie-C 26-May-15 5:44am View
   
You have reposted this question.
You don't have to. Please wait for answer.
Frankie-C 26-May-15 5:40am View
   
First of all you can start a debugging section to check what is the error and maybe you'll find it by yourself.
2nd The info's are not enough to find the problem.
Show us the definition of AreaShopList_T.
As a hint, free() complains when the memory block is corrupted...
Frankie-C 26-May-15 5:06am View
   
Thanks
Yes really a lot... :)
Frankie-C 26-May-15 2:54am View
   
:)
Frankie-C 25-May-15 8:22am View
   
What have you tried?
Frankie-C 25-May-15 8:10am View
   
Thanks
Frankie-C 25-May-15 7:21am View
   
What you told us is not sufficient.
Surely there is an heap corruption, this can be due to wrong type interpretation, or wrong coding somewhere.
Show us generateArray() code.
Frankie-C 25-May-15 3:25am View
   
You're welcome.
Thanks for the 5 and let me know if you solved the problem.
Frankie-C 24-May-15 17:47pm View
   
Not so easy as you say...
The code works when you don't touch the packets?
Do you test between machines on the same subnet (no gateways or routers between) or on multiple subnets and even internet?
Encryption works on machine on the same subnet?
Frankie-C 24-May-15 12:16pm View
   
Yes This case can sound a little bit strange... I amended the comment.
Thanks for the 5.
Frankie-C 24-May-15 12:11pm View
   
No Sergey, sometimes a pc is used as a public terminal and need to start-up and run an application automatically.
If you follow the second link I provided the user describe a typical use in a public library.
In this case maybe it is a little bit uncommon...
Frankie-C 24-May-15 9:53am View
   
Sorry Rustam, with so much limitations I can't figure out how to access editor to compute the line. If I can find a workaround I'll let you know.
Frankie-C 24-May-15 8:51am View
   
To do what you want maybe you need to define what's your page dimension (pixels, cm, inches) than get the chars heights of your text lines in the same format. Scan lines and each time you reach the dimension of the page increase the page count for one more...
You want take your pages count in a pages structure array that hold beginning and ending line for each page...
Frankie-C 24-May-15 5:42am View
   
When no bug appears in debugging session in 99% of cases the problem is an uninitialized pointer or variable (under debug the bss section of executables is initialized to 0 by OS).
I suggest you to have a better look on pointers and variables (i.e. if you check a pointer to be null to reinitialize it, and you have never initialized it to null on first run, the code will work well under debug, but will crash under normal execution with memory exception).
Frankie-C 24-May-15 5:35am View
   
+5 ;D
Frankie-C 23-May-15 12:32pm View
   
And the downvote is for? Do you hate google or NetBeans?
Please tell me what hurted you? :D
Frankie-C 22-May-15 13:08pm View
   
+5
Frankie-C 22-May-15 13:02pm View
   
He can force the app to be used to open file so won't run something:
system("notepad.exe " + file);
Frankie-C 22-May-15 11:37am View
   
Thanks Andi
Frankie-C 22-May-15 8:36am View
   
Don't use solutions for comments please.
Frankie-C 22-May-15 7:10am View
   
If I well understood your requirements calling the functions I indicated will give you the Id of the invoking process.
Is this what you were looking for? Or you required the process Id to do something else?
Frankie-C 22-May-15 7:06am View
   
Thanks Sergey.
I have not added any more explanation because what I have understood is that he created an application and a shared library. Because the library is included in assembly at runtime he want a system to identify the the process that is running the app that in turn referenced the shared code.
A Dll, managed or unmanaged, runs in the calling process, so getting current process Id give the referencing process. :-)
Frankie-C 21-May-15 6:10am View
   
Posting many times same question don't give you better chances to get an answer!
Please don't repost.
Frankie-C 21-May-15 3:53am View
   
Grazie Carlo
Frankie-C 20-May-15 10:06am View
   
You have made also another error XORing the data to encrypt with the destination value.
I fixed it now.
If it's ok accept the answer please.
Frankie-C 20-May-15 10:05am View
   
Deleted
You have made also another error XORing the data to encrypt with the destination value.
I fixed it now.
If it's ok accept the answer please.
Frankie-C 20-May-15 10:01am View
   
You're right! I have not noticed it!
I made a fast test in debug mode, where the array test1 was filled with 0's...
Frankie-C 20-May-15 9:37am View
   
I updated the solution with a library link and some other usefull links.
If it's ok for you accept the answer.
Frankie-C 20-May-15 9:03am View
   
Deleted
On my machine works.
Check that you have replaced the right parts. To simplify I have updated answer inserting the whole block.
Frankie-C 20-May-15 9:02am View
   
It's a simple xoring of values with a salt, in this case of the same lenght of the sequence to encrypt.
So simply exoring the result wit the salt will give back the value:
10101 xor 01011 = 11110
11110 xor 01011 = 10101
Frankie-C 20-May-15 7:31am View
   
Have you read the whole serie of articles in the site whose link I attached?
This page [http://mobiletidings.com/2009/02/11/more-on-the-sms-pdu] details very well the PDU, phone number encoding, 7 bits gsm encoding etc.
Frankie-C 19-May-15 10:08am View
   
I agree.
Then maybe you have to make a prescan of the buffer. I.e. loook for end of sentence or the like ... :(
BTW 10k is not a threat for a modern OS ... unless you make this online simultaneously on many concurrent threads...
Frankie-C 18-May-15 4:47am View
   
Are you trying to launch the same executable that in turn relaunch itsels and so on?
Frankie-C 18-May-15 4:38am View
   
Rajinesh it is very simple: the storage attribute applies to the whole structure, meaning that all variables inside the structure get the attribute. But in your structure you have declared a *pointer* to a struct, not a struct! So the pointer is permanent and holds indefinitely the value you have set into it, but the nested structure referred by the pointer have *its own storage class* as you put in the declaration.
In my example I declared the substructure at module level to make it permanent, if you create it with GC allocation, or as an automatic variable (created on the stack of a procedure) oof course you will fail to access it when, respectively, the GC recollects memory or when you leave the function.
To dynamically create the structures you can follow the example from pwasser uusing the new operator in C++, or you can use the malloc(sizeof(structure)); in C.
If this satisfy your question please accept the answers.
Frankie-C 17-May-15 18:01pm View
   
Please use replay button on the comment to which you want answer don't post a solution...
Frankie-C 17-May-15 17:58pm View
   
my 5
Frankie-C 17-May-15 17:54pm View
   
This thread is 4 years old...
Frankie-C 17-May-15 13:59pm View
   
Absolutely!
To give some rating could be ?
float Platform1Rating = (Platform1 - Platform2)/platform2*100.0;
BetterPlatform = max(Platform1Rating, Platform2Rating );
Frankie-C 17-May-15 13:46pm View
   
The predicate ... Great! :-D
Frankie-C 17-May-15 13:21pm View
   
sed. +5
Frankie-C 17-May-15 12:16pm View
   
Not a good idea to insert an email address in plain text... I suggest you to remove it before you'll get full of spam.
Anyway what you mean to give print command? Which command?
Frankie-C 17-May-15 11:39am View
   
I understood that he is using VBA in Access.
Frankie-C 17-May-15 9:29am View
   
Please don't use all capital letters, we can hear you, you don't have to ... SHOUT! :-)
Frankie-C 17-May-15 9:23am View
   
Kornfeld already said all. Just a small suggestion, add:
MsgBox(SQL)
And check if everything is ok.
PS final semicolon is missing...
Frankie-C 17-May-15 3:52am View
   
Once again because my english is not as good as I would like, please read my first sentence in the answer "maybe I understood what your problem is". I suppose the problem is that, of course there are many other meaning that you outlined. Maybe I'm wrong at all. I don't want to be rude at all :-)
Anyway there is not a sound from the asker, for this reason I said that maybe we are both wasting time, seems he is no more interested... :-D
Frankie-C 17-May-15 3:17am View
   
I think this is really a waste of time. The last sentence is:
"will the nestedfirst structure value will remain available between different file(.c) calls, say i initialized it at file1.c and move to file2.c then comeback to file1.cs will i find its value unchanged if not what should i do to make it happen."
Have you seen "say i initialized it at file1.c ..." we have to suppose that he has initialized everything :-).
What nf is pointed to is something that he has managed, if he put a pointer to a struct he has to update that pointer, if he doesn't do that he will have a memory problem, not different data between modules.
In my opinion he has simply declared the same variable in different modules, that leads to different instances, one for each module, each one with its own data.
We are criticizing our answers while no clarification is coming from user. His poor english (even worst than mine :-)) lets open any interpretation.
Even in your solution the use of 'static' on the pointer declaration can be opinablle if that pointer have to be shared between modules it will be not, or will trigger a compiler error if declared 'extern' also... ;-)
Frankie-C 16-May-15 10:48am View
   
Of course it's not assigned (and a lot of many many other initialization are missing), this is an just an *example* to explain how to make objects visible between modules, it is not a complete program! :-)
The user is not complaining on crashes or memory exceptions on null pointers, so we *must* assume that he knows how to deal with that.
Please concentrate on the question: how to make available same data aggregate between different modules. ;-)
Frankie-C 15-May-15 8:55am View
   
Ya, thanks
Considering that there is no valid answers why has not been removed at all? Bah!
Thank you again
Frankie-C 15-May-15 7:18am View
   
What is a net-setter?
Have you checked for viruses?
Frankie-C 15-May-15 5:49am View
   
Dear Anurag, the implementation of parallel execution, or better defined as concurrent execution, is not as simple unfortunately. I had the wrong impression that you were a little bit more skilled, and from your answer I deduced that the problem could simply be related to variables to handle locally (as with thread local storage), but now I think that it will be a not easy to give you a concise and specific answer.
I can only give you some guidelines for concurrent tasking (multithread objects access).
First of all consider that all your threads will access variables, values, etc in any time and any order. This means that you cannot assume the flow of execution of your functions as sequencial and finite. You have to expect that a variable or whatever object can change unexpectedly.
What you have to do: analyze your software flow to avoid uncontrolled access to shared objects (fence the access using sync, mutex or the like), and check that local or temp variables or objects are really local and cannot be altered from other threads.
But the most important point is: your software can really make parallel operations? Because if a computation depends on the previous one it mast be serially executed (i.e. if you compute a new value and use it for the next computation you have a naturally serial execution flow and simply cannot make it parallel!).
Frankie-C 14-May-15 11:21am View
   
Anurag, have read the links? TLS have to be used to create variables local to each thread, not to create threads.
You have to use one of the Parallel.For<tlocal> Methods. See https://msdn.microsoft.com/en-us/library/dd783299(v=vs.110).aspx
Frankie-C 14-May-15 10:54am View
   
And the problem is?
While you explain better to us what the problem is take note of:
- Undefined 'j' and 'x' variables.
- Missing ';' at end of line: sum = sum[j]
- sum redefined locally on line: int m=0, sum=0;
Frankie-C 14-May-15 9:04am View
   
What you mean with "When first Thread is done with all the calculation clears the data."?
Which data are you cleaning? Is there any static or common data that you clear? Do you allocate per-thread local data using TLS storage?
Frankie-C 14-May-15 3:31am View
   
+5
Frankie-C 14-May-15 3:11am View
   
Dear Rajneesh I thinnk that you have not fully understood what I said. This maybe is in part my fault so I'll try to be more clear.
In my example:
------------------------------------------------------------------------------
typedef _tagMyStruct
{
int a;
struct _tag_Struct2
{
float c;
int d
} MySecondStruct;
} MyExampleStruct;
---------------------------------------------------------------------------------
The inner struct _tag_Struct2 is fully defined *inside* the main structure _tagMyStruct and int this case also struct _tag_Struct2, with all his members, will be statically allocated.

The way you declared your structure:
--------------------------------------------------------------------------------
struct eg {
struct nestedstruct *nsvar;
int n;
};
--------------------------------------------------------------------------------
The structure itself will be allocated statically (permanent), same allocation will have the integer n and the *pointer* to structure nestedstruct. The pointer, *not* the structure nestedstruct. If you want to make nestedstruct static also you have to insert in your structure the whole nested structure, not a pointer to it!
Is it clear now?
Frankie-C 13-May-15 11:04am View
   
You don't have nested structures in your example, but pointers to other structures.
Again: explain better what you mean by 'page', what is a page?
If you declare a pointer to something, the pointer remains unchanged, but to the object to which it points can change in any way.
Frankie-C 12-May-15 10:06am View
   
And you have to provide an error handling too.
T Stack<t>::top()
{
if(stkptr > 0)
return stackArray[stkptr];

//stkptr is <= 0 what you do?
//return 0, throw an exception? what?
}
Frankie-C 12-May-15 9:47am View
   
Why you think that if such code exists Google have not copied it yet?
Frankie-C 12-May-15 9:38am View
   
My 5.
Anyway maybe worth a more detailed explanation.
pop() get and remove the value from the stack that is no more available.
I.e in the case:
if(stk.pop() > Max)
{
Max = stk.pop(); // This statement looks Wierd..
}
you get the value from stack, compare it to Max, and, if it is bigger you assign to Max the *next stack value* (not the one you compared that is no more available on the stack).
With the proposed solution the correct value is assigned to Max.
Frankie-C 12-May-15 8:38am View
   
Thanks Sergey.
You gave the correct answer, but let me add, for sake of precision and especially for the novices that don't know, that in C the name of an array is the address where it begins (or the address of the first element). So in C where is required an array simply pass the name of the array.
Moreover C don't checks bounds, it's up to you to avoid memory corruption.
Frankie-C 12-May-15 5:48am View
   
Sure +5
Of course there are some general lines for each language...
Frankie-C 12-May-15 5:38am View
   
In some countries (i.e. UK) the ZIP codes are Alphanumeric.
The most recent revision of the C standard (2011) has definitively removed the function gets() from its specification.
The function is deprecated in C++ (as of 2011 standard, which follows C99+TC3).
Actuallly is available the safe extension gets_s(), under the technical report ISO TR24731-1, in C99, C11 and C++11.
Frankie-C 11-May-15 6:54am View
   
The user is the same that posted question on 'I want learn C++',etc.
Do you want learn or just spam questions?
Frankie-C 11-May-15 5:50am View
   
Don't repost the same *not a question*, but make it more clear if you really have something to ask!
Frankie-C 10-May-15 11:05am View
   
I think that he refers to CGI that were originally based on C.
Frankie-C 10-May-15 6:54am View
   
See http://en.wikipedia.org/wiki/142857_%28number%29, Repeating decimal and Cyclic numbers.
Frankie-C 2-May-15 18:30pm View
   
Ok I made a check and found some other minor errors.
I created a more sophisticated version, but this is the last I do.
Look the software and try to understand how it works.
Frankie-C 2-May-15 15:51pm View
   
That you understood the error and you're asking how to solve it is a good solution...
Does this solve your problem? :-D
Use comments to answer to comments, not solutions please.
Frankie-C 2-May-15 9:30am View
   
Dunno what to tell you :( It works well for me.
Try to copy the received file on a memory stick than binary compare it with the original to try to understand what's wrong...
Frankie-C 1-May-15 13:12pm View
   
Thanks Richard
Frankie-C 1-May-15 11:21am View
   
Why you suppose that such a function exist in C standard libraries?
Where you get it?
Frankie-C 1-May-15 4:50am View
   
It is a problem with switches on command line invocation of g++.
See my answer below.
Frankie-C 30-Apr-15 13:41pm View
   
I fully agree with Sascha, I think that your problem is that your targets are too 'advanced' to be reached just reading a tutorial or a book.
Books generally are oriented to beginners, and expose the very basic of whatever. Net tutorial, articles and similiar are even worst from your requirements point of view.
Consider that it is very improbable to read something and write a GIMP like photo editor, but this was done anyway by years of study, practice and trial.
If you're so committed in trying to reach the goal as you are in your report above I'm sure that in these months you got so many knowledge, even if still not enough, that others would have took 2-3 times more time. And you're not even aware of this.
Try to make a balance of what you were able to do before to start and now ;-)
Frankie-C 30-Apr-15 11:00am View
   
Yes, that's why I said "if this works check the version of g++" ...
Frankie-C 30-Apr-15 8:47am View
   
I want win lottery, but I can't...
Frankie-C 30-Apr-15 4:38am View
   
It seems the compiler interpreted the slash as the divide operator :(
Try to change C++ comments '//' with standard '/* commment */'
If it works check which version of g++ you're using...
Frankie-C 30-Apr-15 3:20am View
   
It works for me.
Is your systems Linux or what?
The two machines have the same OS?
Frankie-C 29-Apr-15 9:03am View
   
If the problem is present only for files > 2Gb the probllem is that in my sample the length variablle is a 32 bits integer.
Frankie-C 29-Apr-15 7:34am View
   
Thanks
Frankie-C 29-Apr-15 7:31am View
   
Have you updated server address with the address of the server machine?
Frankie-C 28-Apr-15 6:32am View
   
See update of my previous comment.
Your code while working is too simple.
You should start your connection transfering a small buffer containing file name and its dimension in bytes, than after an acknowledge from client (that can be simply retransmission of the received buffer), you can start transfer in small chunks (I suggest 512bytes each because is the minimum size supported by ethernet frame). The client can read each received block and store it up to reaching the final size.
Frankie-C 28-Apr-15 6:19am View
   
But you haven't told us which errors you get when running on different machines. Or everything runs flat with no errors and simply you don't find the file?
I think the problem is that the send/receive functions doesn't handle the whole buffer you have filled with data in one call, you have to check if all data has been sent and recall receive or send if required.
When client and server runs on the same machine probably it works because it become a pipe more than a connection and memory is interconnected by machine bus, but when sending on the wire then the network physical media come in and the bandwidth becomes smaller. Here something can change.
Read http://stackoverflow.com/questions/12657063/does-send-allways-send-whole-buffer
Frankie-C 28-Apr-15 5:23am View
   
I think that there is a big confusion here... :)
To make a connection don't means that you can transfer files unless you add code for file transfer.
I don't see such code in your program, and I'm really curious now: what exactly you do to 'transfer a file'?
Frankie-C 28-Apr-15 4:44am View
   
What file?
You mean the message "Hello World"?
If so which errors you got?
Frankie-C 28-Apr-15 3:54am View
   
You already solved, but for sake of precision I'll detail it better:
The server is waiting for incoming connections, and it waits for connections at local machine address. Putting INADDR_ANY as address for the server means wait for connections and manage all of them directed to *this* machine (localhost is always referred gto local machine IP address).
On the client side however you cannot say connect to a server on localhost address (that is the machine where the client is running, but not the server). You must specify the address where the connection should look for the server.
I hope it is clear now.
Frankie-C 27-Apr-15 11:07am View
   
using ping can you reach the systems you want to talk each other?
I mean from system 1 pinging system 2 works?
And the reverse ? (pinging system 2 from system 1).
Are you sure that the port you are using, 6777, is not blocked by a firewall ? Have you made a trial using a different port?
Frankie-C 26-Apr-15 13:15pm View
   
While is not a real option to use a compiler to generate assembler to reuse the point is that you need a DOS compiler you can't use GCC!
See my other solution...
Frankie-C 26-Apr-15 12:24pm View
   
+5
Frankie-C 17-Apr-15 11:17am View
   
You mean ready data as in here: https://msdn.microsoft.com/en-us/windows/desktop/aa394308(v=vs.85).aspx
Frankie-C 13-Apr-15 6:55am View
   
And the question is?
Frankie-C 12-Apr-15 16:31pm View
   
What don't work? It works pretty good.
On what values it fails for you?
Frankie-C 12-Apr-15 15:07pm View
   
In your original code you messed up the conditions for 'correct' value and 'wrong' one.
in the line:
if ((h1 < '0' || h1 > '2') || (h2 < '0' || h2 > '9') || (m1 < '0' || m1 > '5') || (m2 < '0' || m2 > '9'))
you checked all wrong conditions, you must have returned immediatly as 'wrong' format. But you added another check:
if (h1 == '2' && h2 greater than '3')
So all wrong inputs, but not having hour bigger that 23 become correct ;-)
Maybe in your checks reverting the conditions you got an error again making wrong all 'correct' values less than 23.
The correct coding of your test should have been:
if ((h1 < '0' || h1 > '2') || (h2 < '0' || h2 > '9') || (m1 < '0' || m1 > '5') || (m2 < '0' || m2 > '9'))
{
printf("The time is not in the format HH:MM.");
return 1;
}
else if (h1 == '2' && h2 > '3')
{
printf("The time is not in the format HH:MM.");
return 1;
}
Frankie-C 12-Apr-15 13:32pm View
   
Have you realized that anyway your code just make one iteration only because the while condition is wrong?
Frankie-C 12-Apr-15 11:06am View
   
As general rule, for all systems and all languages, always *be sure* that your code have no polling! On any decent OS there is always a waiting primitive that allows to your app to give back control to OS and suspend use of CPU. Then the OS will call your app back to life when conditions is on.
A polling just keep the CPU running consuming power...
Frankie-C 29-Mar-15 17:38pm View
   
There are always ways to do it...
Think about stack... or dereferenced addressing, or ...
Frankie-C 17-Mar-15 12:41pm View
   
Nice piece of code. :)
Frankie-C 17-Mar-15 6:51am View
   
What is your physical connection between machines? Like the one below?
<pre lang="text">
+-------- +
+----+ Windows | 192.168.1.68
+----------+ +--------+ | +---------+
| Gateway +----+ switch +-----+
+----------+ | +-----+
192.168.1.1 +--------+ | +----------+
+---+ Linux | 192.168.1.128
+----------+
</pre>
If you ping the Linux server from windows can you see it?
And the reverse?
From windows machine is all ok?
Are you sure that the Linux server IP address is effectively 192.168.1.128 ?
Frankie-C 14-Mar-15 14:10pm View
   
Your approach is wrong. You can't try to code all possible distribution of formats in the string, result: there will always be a reason for the function to fail.
First of all don't put more statements on the same line the readability is terrible and coding errors are more difficult to trace even debugging.
Try to rewrite your function in a sequential form: look for the format specifier % each cycle copying to output all chars before you find a %.
When you find it make the conversion and add it to the result.
About your use of dynamic memory it is not optimized. Try allocating a reasonable large buffer at beginning, than check if you still have space to add something and if not reallocate still adding a reasonable chunk (the optimum value should always be the page allocation of the system where you are working. I.e. 4096 for x86). Consider that each time you reallocate memory the system could choose a different physical memory and have to copy all your data on the new memory and this is time consuming (a good MM generally don't do this reusing physical pages and mapping them on a new contiguous address, but you can't exclude it!).
Frankie-C 14-Mar-15 14:09pm View
   
Deleted
Your approach is wrong. You can't try to code all possible distribution of formats in the string, result there will always a reason for the function to fail.
First of all don't put more statements on the same line the readability is terrible and coding errors are more difficult to trace even debugging.
Try to rewrite your function in a sequential form: look for the format specifier % each cycle copying to output all chars before you find a %.
When you find it make the conversion and add it to the result.
About your use of dynamic memory it is not optimized. Try allocating a reasonable large buffer at beginning, than check if you still have space to add something and if not reallocate still adding a reasonable chunk (the optimum value should always be the page allocation of the system where you are working. I.e. 4096 for x86). Consider that each time you reallocate memory the system could choose a different physical memory and have to copy all your data on the new memory and this is time consuming (a good MM generally don't do this reusing physical pages and mapping them on a new contiguous address, but you can't exclude it!).
Frankie-C 14-Mar-15 14:06pm View
   
Deleted
Your approach is wrong. You can't try to code all possible distribution of formats in the string, result there will always a reason for the function to fail.
First of all don't put more statements on the same line the readability is terrible and coding errors are more difficult to trace even debugging.
Try to rewrite your function in a sequential form: look for the format specifier % each cycle copying to output all chars before you find a %.
When you find it make the conversion and add it to the result.
About your use of dynamic memory it is not optimized. Try allocating a reasonable large buffer at beginning, than check if you still have space to add something and if not reallocate still adding a reasonable chunk (the optimum value should always be the page allocation of the system where you are working. I.e. 4096 for x86). Consider that each time you reallocate memory the system could choose a different physical memory and have to copy all your data on the new memory and this is time consuming (a good MM generally don't do this reusing physical pages and mapping them on a new contiguous address, but you can't exclude it!).
Frankie-C 13-Mar-15 12:40pm View
   
This is a trip&Trick not an article and can have no code. It should simply lead you to some direction.
Frankie-C 10-Mar-15 7:32am View
   
I've no direct experience on AIX, but the command for not blocking sockets should be FIBNREAD.
I wondered that another reason for select to signal data when it is not present could be the presence of Out-Of-Band data. On some systems it is possible to set socket to ignore OOB data, or you can try to intercept the SIGURG signal.
Frankie-C 10-Mar-15 4:58am View
   
You're welcome.
I've not understood what you mean for rate of flow?
Frankie-C 9-Mar-15 10:15am View
   
Deleted
The code blocks until no data is available. In some cases when no data is received the recv will stuck.
Have considered to use non blocking mode, or more easy to use a select to check for data availability? Select permits you to set a timeout.
Moreover check your code on received data, the use of stpcpy suppose that the received data always ends with a nul. Because you are not guarantee that the whole data block sent will be received in one cycle maybe you get something not ended by nul that when passed to string routines can lead to a memory violation.
More safely you can use stpncpy, passing the received chars len.
Frankie-C 8-Mar-15 14:44pm View
   
Does google work on your machine?
Frankie-C 7-Mar-15 15:49pm View
   
Yes, it works, but is 8086 pure 16 bits code.
You cannot compile it under a 32 bits OS because of the pointers size.
To use it under 32 bits OS you have to change pointers size:

mov esi, arr ;register si points to base array
xor bx,bx ;BX=0
mov al, BYTE PTR[ROW]
cmp al, BYTE PTR[ESI+BX] ;make comparison, address is SI(=arr)+BX(=index)
je IsEqual ;Match

For 64 bits OS:

mov rsi, arr ;register si points to base array
xor bx,bx ;BX=0
mov al, BYTE PTR[ROW]
cmp al, BYTE PTR[RSI+BX] ;make comparison, address is RSI(=arr)+BX(=index)
je IsEqual ;Match

Thanks for the 5...
Frankie-C 7-Mar-15 11:00am View
   
If you read unicode chars you have to be sure to read complete wide chars (2 bytes) this could be accomplished by allocating buffer as wchar_t or an even number of bytes.
The conversion from big endian to little endian must be the simple swap of high order byte and low order byte of the wchar_t. Something as:
wchar_t SwapWchar(wchar_t wc)
{
wchar_t u = wc >> 8;
return (wc << 8) & u;
}
Using the former conversion that used 32 bits vars on the last conversion would have swapped up to 2 bytes not belonging to the buffer yet the stack corruption.
If this solves your problem please accept the solution.
Frankie-C 6-Mar-15 7:28am View
   
What I see is a big mess. First of all the functions above are converting from double word (32 bits), unicode chars are word wide (16 bits).
Now please answer these questions:
1) You are reading on byte basis, and the number of bytes read is only dependent on the buffer size that you specify?
2) Your input stream is in big endian format and you need to converti it to little endian (INTEL)?
3) Your buffer size is always even?
Please post a comment not other solutions.
Frankie-C 5-Mar-15 9:22am View
   
To do what?
Frankie-C 2-Mar-15 4:12am View
   
Send how? Using a pigeon?
Frankie-C 1-Mar-15 7:09am View
   
No magic here to see your system.
Provide info: what program, where it timeout, what it do, etc...