"C Language Learning" 04__goto,void,extern,sizeof Analysis __c language

Source: Internet
Author: User
Tags modifier

1:goto disabled

The meaning of 2:void

void modifier function return value and parameters
If the function does not return a value, it should be declared as a void type
If the function has no arguments, it should declare that its argument is void
The void modifier returns values and parameters only to indicate that none

void variable not present

The C language does not define void as the alias of how much memory

The meaning of void pointers
C language stipulates that only pointers of the same type can assign values to each other
void* pointer as a left value for "receive" any type of pointer
The void* pointer is assigned to the other pointer as a right value to force type conversion

int* pi = (int*) malloc (sizeof (int));
char* pc = (char*) malloc (sizeof (char));
void* p = NULL;
int*  PNI = NULL;
char* PNC = NULL;

p = Pi;//ok
PNI = p;//oops

p = pc;//ok
PNC = p;//oops

The Hidden meaning in 3:extern

extern for declaring externally defined variables and functions
extern is used to "tell" compilers to compile with the C method
C + + compilers and a few variants the C. compiler defaults to compile in its own way
Functions and variables, through extern keys, you can command the compiler to "compile in standard C mode."


sizeof is a built-in indicator of the compiler, not a function
sizeof used to "calculate" the amount of memory that the corresponding entity occupies
The value of the sizeof is determined at compile time

#include <stdio.h>

int main ()
    int A;
    printf ("%d\n", sizeof (a));//4
    printf ("%d\n", sizeof a);//4
    printf ("%d\n", sizeof (int));//4
    GetChar ()
    ; return 0;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.