11-08-2007
It's a historical anachronism from segmented architectures such as the 8086.
Back in the days of yore there was the 8080, this was an 8 bit processor with 16 bit address bus, hence 16 bit pointers.
Along came the 8086, in order to support some level of backward compatiblity it adopted a segmented architecture which let use use either 16 bit, 20 bit or 32 bit pointers depending on the day of the week. Where a pointer was a combination of 16 bit segment register and 16 bit near offset. This lead to the rise of tiny, small, medium, large and huge memory models with near, far and huge pointers.
Other architectures such as 68000 did not adopt this scheme and had what is called a flat memory model.
With the 80386 and true 32 bit mode, all pointers are 32 bit, but ironically are now really near pointers but 32 bit wide, the operating system hides the segments from you.
10 More Discussions You Might Find Interesting
1. Programming
void main()
{
int a={1,2,3,4,5,6,7,8,9,10};
int *p=a;
int *q=&a;
cout<<q-p+1<<endl;
}
The output is 10, how?
if we give cout<<q it will print the address, value won't print....
if we give cout<<p it will print the address, value won't print....
p has the base addr; q... (1 Reply)
Discussion started by: sarwan
1 Replies
2. Programming
can u tell me the reson that why we should not delete a pointer twice.?
if we delete ponter twice then what happen and why this happen
Regards,
Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies
3. Programming
could any one tell why the following is showing segmentation fault while using **ptr
but working fine using **a
#include<stdio.h>
... (1 Reply)
Discussion started by: useless79
1 Replies
4. Programming
Hi,
I am trying to divide my input to different type of out puts for some other use.
ex: logical_name : jkl00001
expected out put : model=jkl and num=00001
here is the code i actually written
/*******************************************************************/
void... (11 Replies)
Discussion started by: jagan_kalluri
11 Replies
5. Programming
If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it:
(1) one is to pass a pointer-to-pointer parameter, like:
int my_malloc(int size, char **pmem)
{
*pmem=(char *)malloc(size);
if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies
6. Programming
Can anyone tell me what the following statements do?
float (*tab);
tab=(float (*)) calloc(MAXCLASS,
(MAXCLASS+1)*sizeof(float)); (3 Replies)
Discussion started by: littleboyblu
3 Replies
7. Programming
Hi,
Can anyone tell me how i can declare and allocate dynamically an array of pointers to structured type?? Is declaration something like this:?
struct_name ** array; (1 Reply)
Discussion started by: littleboyblu
1 Replies
8. Programming
Hi guys, I'm trying to understand pointers in C and made a simple example and I've problems with It.
Can someone help?
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int f1(char **str_);
int main(int argc, char **argv)
{
char *str = NULL;
f1(&str);
... (3 Replies)
Discussion started by: pharaoh
3 Replies
9. Programming
This code is to print out the program name and arguments list one by one:
1 #include<stdio.h>
2
3 void main(int argc, char *argv)
4 {
5 int iCount = 0;
6 while (iCount < argc) {
7 printf("argc:%d\t%s\n",iCount, argv);
8 ... (14 Replies)
Discussion started by: yifangt
14 Replies
10. Programming
Here are two programs that pass a pointer to a variable but behave differently. Shouldnt the i in second program be 0 after the function call?
#include<stdio.h>
void changeI(int *i)
{
*i = 10;
}
int main(void)
{
int i=5;
printf("%d before\n", i);
changeI(&i);
printf("%d... (1 Reply)
Discussion started by: dragonpoint
1 Replies
index(3C) Standard C Library Functions index(3C)
NAME
index, rindex - string operations
SYNOPSIS
#include <strings.h>
char *index(const char *s, int c);
char *rindex(const char *s, int c);
DESCRIPTION
The index() and rindex() functions operate on null-terminated strings.
The index() function returns a pointer to the first occurrence of character c in string s.
The rindex() function returns a pointer to the last occurrence of character c in string s.
Both index() and rindex() return a null pointer if c does not occur in the string. The null character terminating a string is considered
to be part of the string.
USAGE
On most modern computer systems, you can not use a null pointer to indicate a null string. A null pointer is an error and results in an
abort of the program. If you wish to indicate a null string, you must use a pointer that points to an explicit null string. On some
machines and with some implementations of the C programming language, a null pointer, if dereferenced, would yield a null string. Though
often used, this practice is not always portable. Programmers using a null pointer to represent an empty string should be aware of this
portability issue. Even on machines where dereferencing a null pointer does not cause an abort of the program, it does not necessarily
yield a null string.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO
bstring(3C), malloc(3C), string(3C), attributes(5), standards(5)
SunOS 5.10 24 Jul 2002 index(3C)