Any windows application has only single entry point named "main" for console application or "WinMain" for Windows application. Maybe you need multithreading to start simultaneously multiple functions? I mean something like this:
DWORD WINAPI _Thread1(LPVOID pParam)
{
//do something
return 0;
}
DWORD WINAPI _Thread2(LPVOID pParam)
{
//do something
return 0;
}
void main(void)
{
HANDLE hThreads[2];
hThreads[0] = CreateThread(NULL, 0, _Thread1, NULL, 0, NULL);
hThreads[1] = CreateThread(NULL, 0, _Thread2, NULL, 0, NULL);
WaitForMultipleObjects(2, hThreads, TRUE, INFINITE);
}
Can there be a multiple main function in one c++ or c program?
no!
Reply:you can create multiple functions. However there can only be one Main function
Reply:Main function is the part from where the compiler begins to read the program. Just like a book cannot have two beginnings, a C/C++ program cannot also have two main functions.
Reply:nope!
Reply:No can do...
Monday, May 24, 2010
How does free function work in C language?
How it works exactly is compiler dependent. It may also depend on whether or not you are building with debugging information turned on.
free is going to release memory that you've allocated and return it to the heap for reallocation. Generally, the memory manager as a linked list of blocks of memory that it has allocated. It is going to search the list for your block of memory, remove the link from the allocated list and insert it in the list of free blocks of memory. It may also attempt to merge you block with adjacent blocks of free memory to maximize the size of available blocks.
If you are running Microsoft C++, the debug memory manager will check a couple of bytes that are added to the front and back of the block to be sure that you haven't overflowed when you used it. It will also write a specific byte pattern to the block so that it is easily recognized as deallocated if you use a pointer to it after it has been released.
How does free function work in C language?
i haven't heard about this free function though i am good in C programming. Please give us the enough information about that funcion like its syntax or the header file for that function. So we can understand what you talking about.
free is going to release memory that you've allocated and return it to the heap for reallocation. Generally, the memory manager as a linked list of blocks of memory that it has allocated. It is going to search the list for your block of memory, remove the link from the allocated list and insert it in the list of free blocks of memory. It may also attempt to merge you block with adjacent blocks of free memory to maximize the size of available blocks.
If you are running Microsoft C++, the debug memory manager will check a couple of bytes that are added to the front and back of the block to be sure that you haven't overflowed when you used it. It will also write a specific byte pattern to the block so that it is easily recognized as deallocated if you use a pointer to it after it has been released.
How does free function work in C language?
i haven't heard about this free function though i am good in C programming. Please give us the enough information about that funcion like its syntax or the header file for that function. So we can understand what you talking about.
Given the function ax2+bx+c, and a is negative, how would you find b?
the y-intercept is also negative
FYI the 2 means squared.
Given the function ax2+bx+c, and a is negative, how would you find b?
Solve the formula for b
ax2+bx+c=0
ax2+c=-bx
ax2+c
--------=-b
x
-(ax2+c)
------------=b
x
Reply:given the function ax2+bx+c, and a is negative, how would you find b?
the y-intercept is also negative
Assume x is a real number
f(x) = ax^2+bx+c
f(0) = c %26lt; 0 , y intercept
from the quadratic equation
x = -b +/-sqrt(b^2 - 4ac)] / 2a
Since a is negative and c is negative, 4ac is positive.
For the radical to be a real number:
b^2 %26gt;= 4ac
b %26gt;= 2sqrt(ac) or b %26lt;= -2sqrt(ac)
That is the best I can do.
Reply:ax²+bx+c
y intercept is negative
a%26lt;0
c%26lt;0
FYI the 2 means squared.
Given the function ax2+bx+c, and a is negative, how would you find b?
Solve the formula for b
ax2+bx+c=0
ax2+c=-bx
ax2+c
--------=-b
x
-(ax2+c)
------------=b
x
Reply:given the function ax2+bx+c, and a is negative, how would you find b?
the y-intercept is also negative
Assume x is a real number
f(x) = ax^2+bx+c
f(0) = c %26lt; 0 , y intercept
from the quadratic equation
x = -b +/-sqrt(b^2 - 4ac)] / 2a
Since a is negative and c is negative, 4ac is positive.
For the radical to be a real number:
b^2 %26gt;= 4ac
b %26gt;= 2sqrt(ac) or b %26lt;= -2sqrt(ac)
That is the best I can do.
Reply:ax²+bx+c
y intercept is negative
a%26lt;0
c%26lt;0
I am calling a function in a C DLL that I wrote from C#. How do I trace into it with the debugger?
you need to start the debugger with the ability to trace into managed and native code.
I have acomplished that by starting the application from the command line, then attached the debugger to the process and in the dialog selected both managed and native code.
In VS2005 go to Debug menu, select attach to process in the dialog that appears in the middle of the dialog you will see where you can select what kinds of code you want to debug.
Hope this helps.
I am calling a function in a C DLL that I wrote from C#. How do I trace into it with the debugger?
Try this instead: under the properties tab of the solution, check 'enable unmanaged code debugging'. You should be able to debug right into the DLL. BTW, if you had, say, c++ code calling managed code (and yes, it can be done), you'd select Debugger Type=mixed under the solution's properties.
lady palm
I have acomplished that by starting the application from the command line, then attached the debugger to the process and in the dialog selected both managed and native code.
In VS2005 go to Debug menu, select attach to process in the dialog that appears in the middle of the dialog you will see where you can select what kinds of code you want to debug.
Hope this helps.
I am calling a function in a C DLL that I wrote from C#. How do I trace into it with the debugger?
Try this instead: under the properties tab of the solution, check 'enable unmanaged code debugging'. You should be able to debug right into the DLL. BTW, if you had, say, c++ code calling managed code (and yes, it can be done), you'd select Debugger Type=mixed under the solution's properties.
lady palm
What is a callback function ? Explain in C , C++ and WIN API environment.?
It was asked in assessment test but I couldn't answer correctly. I'm not familiar with WIN API environment too. Can u plz help me on these ?
What is a callback function ? Explain in C , C++ and WIN API environment.?
Callback function— callback procedure with return value.
Callback procedure— procedure to be called from external execution flow than the execution flow (main) of unit that contains procedure. The description refers to executed unit, ex. binary executable file loaded into memory and executed as *self* operating system task. Such procedure operates out of direct-inherited environment of the main execution flow.
In C simple example of callback function is one passed as argument with "sort()". This function is next used for comparing and is called before "sort()" returns to main execution flow from C library.
[C++— omited answer.]
In Windows API callback functions are used for events (messages) [explained in earlier answer] and reporting states of asynchronous operation.
Usually pointer to callback function is passed as argument to function that initiates some operation.
Reply:A callback function is a function that executes when an event occurrs in the GUI. For example, you press the back button on a browser, and the callback function reloads the previous page. They can respond to clicks, double clicks, key down, key up, Any event.
What is a callback function ? Explain in C , C++ and WIN API environment.?
Callback function— callback procedure with return value.
Callback procedure— procedure to be called from external execution flow than the execution flow (main) of unit that contains procedure. The description refers to executed unit, ex. binary executable file loaded into memory and executed as *self* operating system task. Such procedure operates out of direct-inherited environment of the main execution flow.
In C simple example of callback function is one passed as argument with "sort()". This function is next used for comparing and is called before "sort()" returns to main execution flow from C library.
[C++— omited answer.]
In Windows API callback functions are used for events (messages) [explained in earlier answer] and reporting states of asynchronous operation.
Usually pointer to callback function is passed as argument to function that initiates some operation.
Reply:A callback function is a function that executes when an event occurrs in the GUI. For example, you press the back button on a browser, and the callback function reloads the previous page. They can respond to clicks, double clicks, key down, key up, Any event.
What printf function returns in C?
printf function returns an integer. were the integer is number of characters it had printed using that printf statement..
Eg:
void main()
{
int i;
i= printf("hai");
}
In the above program i will have a value 3 after the execution of the printf.
What printf function returns in C?
it prints the word you would write in () brackets
dont forget to put /n in the end of the statment
ask any computer related problem here which is a open house resource form
http://airtel-broadband.com/webjockey/cl...
Reply:On success, the total number of characters printed is returned.
On error, a negative number is returned.
Reply:Number of characters output, or EOF if there was a problem.
Never checked it though.
Eg:
void main()
{
int i;
i= printf("hai");
}
In the above program i will have a value 3 after the execution of the printf.
What printf function returns in C?
it prints the word you would write in () brackets
dont forget to put /n in the end of the statment
ask any computer related problem here which is a open house resource form
http://airtel-broadband.com/webjockey/cl...
Reply:On success, the total number of characters printed is returned.
On error, a negative number is returned.
Reply:Number of characters output, or EOF if there was a problem.
Never checked it though.
What is function overriding in C++???
Function overriding allows you to write multiple functions with the same name. The compiler differentiates them from each other by the number of and types of the parameters the function takes. The compiler does this by "name mangling". So, for instance, the compiler could internally change
void foo(void); to vFooV(void)
and
void foo(float f); to vFooF(float)
Compilers are free to mangle names any way they want so long as they are consistent. However it is entirely possible that two different compilers will employ entirely different techniques.
The compiler keeps track of which one of the overridden functions is called based on the parameters present in the function call itself.
Note that overriding does not necessarily have anything to do with inheritance. Stand alone functions outside of any class can be overridden.
What is function overriding in C++???
Function Overriding refers to modify the definition of the base class method into the derived class with the same name and signature.
If we change the the definition of a method in a same class but with different signature then it is known as Function Overloading.
Check this out, Function overriding in C++/CLI. http://www.codeproject.com/KB/mcpp/cppcl...
Reply:function overloading is where you can make a function do different things depending on what information you send as parameters to the function.
Actually it isn't the function doing different things, it's multiple functions with the same name that do different things. The function that actually gets invoked depends on what parameters you send.
http://en.wikibooks.org/wiki/Computer_pr...
Reply:Function Overriding happens in the context of inheritance. When a derived class defines a function with the same signature as that from its base class.
e.g you have a base class called vehicle
with a function called "steer vehicle"
maybe you make a class... vehicle :car...
where car, inherits all the properties and functions of vehicle.
and you have the function steer vehicle in the vehicle class.
but now you make a class vehicle: bicycle
and you decide that the steer vehicle function needs to be a bit different, so you can define the function "steer vehicle" again inside the bicycle class. and when you use the steerVehicle function from the bicycle class..... it will use this function, instead of the one from the base class. in otherwords.. over-riding the function in the base class.
hope that makes sense :)
void foo(void); to vFooV(void)
and
void foo(float f); to vFooF(float)
Compilers are free to mangle names any way they want so long as they are consistent. However it is entirely possible that two different compilers will employ entirely different techniques.
The compiler keeps track of which one of the overridden functions is called based on the parameters present in the function call itself.
Note that overriding does not necessarily have anything to do with inheritance. Stand alone functions outside of any class can be overridden.
What is function overriding in C++???
Function Overriding refers to modify the definition of the base class method into the derived class with the same name and signature.
If we change the the definition of a method in a same class but with different signature then it is known as Function Overloading.
Check this out, Function overriding in C++/CLI. http://www.codeproject.com/KB/mcpp/cppcl...
Reply:function overloading is where you can make a function do different things depending on what information you send as parameters to the function.
Actually it isn't the function doing different things, it's multiple functions with the same name that do different things. The function that actually gets invoked depends on what parameters you send.
http://en.wikibooks.org/wiki/Computer_pr...
Reply:Function Overriding happens in the context of inheritance. When a derived class defines a function with the same signature as that from its base class.
e.g you have a base class called vehicle
with a function called "steer vehicle"
maybe you make a class... vehicle :car...
where car, inherits all the properties and functions of vehicle.
and you have the function steer vehicle in the vehicle class.
but now you make a class vehicle: bicycle
and you decide that the steer vehicle function needs to be a bit different, so you can define the function "steer vehicle" again inside the bicycle class. and when you use the steerVehicle function from the bicycle class..... it will use this function, instead of the one from the base class. in otherwords.. over-riding the function in the base class.
hope that makes sense :)
Subscribe to:
Posts (Atom)