Question:
whats the difference between int and int *?
Freddie
2013-05-03 13:59:07 UTC
also the difference between char and char *
and
long and long *

lastly how big in bits are they?
thanks
Five answers:
tbshmkr
2013-05-03 14:09:45 UTC
* is a pointer; a data type whose value refers directly to (or "points to") another value stored elsewhere in the computer memory using its address.

=

int * is an integer pointer

char * is a character pointer

long * is a long integer pointer.
green meklar
2013-05-04 21:44:35 UTC
int* is pointer to int. Correspondingly, char* is pointer to char and long* is pointer to long.



Regardless of the size of the original data type, ALL pointers (within a particular environment) have the same size in memory. On a 32-bit system, it's 32 bits, and on a 64-bit system, it's 64 bits. Furthermore, all pointers have the same format and, to some extent, are interchangeable (for instance you can cast an int* to char* and use that memory location to store a char).
amania_r
2013-05-03 14:27:08 UTC
Answering the second question. The size depends on the machine architecture. In most cases, char is 8 bits, short 16 bits, int and long 32 bits.

Pointers are either 32 or 64 bits depending on the machine architecture and compiler options.

If in doubt you can use the sizeof() directive to find out. E.g. printf("int size %d\n", sizeof(int));
roger
2013-05-03 16:22:17 UTC
char is a single character

char * is a pointer to a character (or several) it contains the address of a character

long is a long integer

long * is a pointer to long that is its value is tha address of a long integer somewhere in memory.



you can use the sizeof operator to get the size of each of them

sizeof char is 1 by definition

char is one byte and is usually 8 bits but it does not have to be.

a byte is the smallest addressable memory unit on a computer.

I have worked on computers with 60 bit bytes.
?
2016-12-26 22:18:31 UTC
almost about "int substantial()", your software would be ignoring any command line arguments. almost about "int substantial(int argc, char *argv[])", you would be waiting to settle for command line arguments, and react in accordance to the way your software is designed. in the case the place you enable passing of arguments, you could loop with the aid of them to verify what the values are: // forget approximately with regard to the 1st parameter, becuase it quite is often the executable's filename int substantial(int argc, char *argv[]) { for (int n = a million; n < argc; n++) { printf("Parameter %d: %sn", argv[n]); } return 0; }


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...