C query
Hi ,
Please make me understand the output of the following code:-
#include
void main()
{
char *s1;
char far *s2;
char huge *s3;
printf("%d %d %d ",sizeof(s1),sizeof(s2),sizeof(s3));
}
Please make me understand the output of the following code:-
#include
void main()
{
char *s1;
char far *s2;
char huge *s3;
printf("%d %d %d ",sizeof(s1),sizeof(s2),sizeof(s3));
}
Replies
-
ameyaamu
i know answer of 1st 1 byte,4 byte,4bytece_nehaHi ,
Please make me understand the output of the following code:-
#include
void main()
{
char *s1;
char far *s2;
char huge *s3;
printf("%d %d %d ",sizeof(s1),sizeof(s2),sizeof(s3));
} -
M.PardhuTHE OUTPUT OF PROGRAM IS
4 4 4
😎PARDHU😎 -
gaurav.bhorkarThe output is 4 4 4 because every pointer is 4 bytes long irrespective of what type it is pointing.
-
devil_radsI just ran the program and it is showing the output as 2 4 4....
Can u please elaborate your ans... -
gaurav.bhorkar
The program gives errors on compiling.devil_radsI just ran the program and it is showing the output as 2 4 4....
Can u please elaborate your ans...
It runs only after modifying in this way
#include
Output: 4 4 4void main() { char *s1; char *s2; char *s3; printf("%d %d %d ",sizeof(s1),sizeof(s2),sizeof(s3)); getch(); }
Using dev-c++ compiler. (or gcc) -
brahmaasthraFirst one char *str : str is a pointer variable which stores an address of a char datatype. So the size is 2 bytes (default). In which you can address from (0000)hexa to (FFFF)hexa. you cant go beyond that.
Second one is char far *str: far pointer increases the addressable locations. where you can give address ranges from (00000000)hexa to (FFFFFFFF)hexa. Ex:- for the monitor output the address is 0800 0000 hexa.
Third one is char huge *str: when far pointer overflows ie gets incremented from (FFFFFFFF) + 1 it again goes to (00000000) hexa. The address is inside the same process.
But in the case of huge if it gets overflow (FFFFFFFF)+1 it goes to the next process 1 0000 0000 hexa. -
gaurav.bhorkar
char *s1;
What is far and huge ?
char far *s2;
char huge *s3; -
Sahithi Pallavice_nehaHi ,
Please make me understand the output of the following code:-
#include
void main()
{
char *s1;
char far *s2;
char huge *s3;
printf("%d %d %d ",sizeof(s1),sizeof(s2),sizeof(s3));
}
hey first can you tell me what is far and huge in your program.?
WINNERS DONT DO DIFFERENT THINGS....THEY DO THINGS DIFFERENTLY.... -
pdpatel
As per my knowledge:ce_nehaHi ,
Please make me understand the output of the following code:-
#include
void main()
{
char *s1;
char far *s2;
char huge *s3;
printf("%d %d %d ",sizeof(s1),sizeof(s2),sizeof(s3));
}
This is happen because simple pointer store in ram and far pointer use video memory. -
Saandeep SreerambatlabrahmaasthraFirst one char *str : str is a pointer variable which stores an address of a char datatype. So the size is 2 bytes (default). In which you can address from (0000)hexa to (FFFF)hexa. you cant go beyond that.
Second one is char far *str: far pointer increases the addressable locations. where you can give address ranges from (00000000)hexa to (FFFFFFFF)hexa. Ex:- for the monitor output the address is 0800 0000 hexa.
Third one is char huge *str: when far pointer overflows ie gets incremented from (FFFFFFFF) + 1 it again goes to (00000000) hexa. The address is inside the same process.
But in the case of huge if it gets overflow (FFFFFFFF)+1 it goes to the next process 1 0000 0000 hexa.
I guess this is the correct answer!!!
You are reading an archived discussion.
Related Posts
hey... i m thnkng abt topic 3d-technology 4 seminar gv me ur view abt dis topic.... it's gud...
hi
how i can prevent someone in a local network from copy files
like docs or video ?????
i wanna make files for read but can not copy
i am...
Please help me with this project.......
The aim is to build a Green circuit that can optimize the energy utilization in a room by avoiding unnecessary energy usage. For
the...
Hello everyone
Iam doing my M.S in aerospace engineering at Chennai, India.
I require a high-speed operating valve that can open and close more than 200 times a second.
Kindly...
hi..i m dipika ...pls help me ..i m in last year ..so tell me abt intresting topic on electrical base ..for seminar ,....also tell me abt some working model ....