“Punteros en c” Código de respuesta

punteros a una función en c

#include <stdio.h>
#include <string.h>

void (*StartSd)(); // function pointer
void (*StopSd)();  // function pointer

void space()
{
    printf("\n");
}

void StopSound() // funtion
{
    printf("\nSound has Stopped");
}

void StartSound() // function
{
    printf("\nSound has Started");
}

void main()
{

    StartSd = StartSound; // Assign pointer to function
    StopSd = StopSound;   // Assign pointer to function

    (*StartSd)(); // Call the function with the pointer
    (*StopSd)();  // Call the Function with the pointer

    space();

    StartSd(); // Call the function with the pointer
    StopSd();  // Call the function with the pointer

    space();

    StartSound(); // Calling the function by name.
    StopSound();  // Calling the function by name.
}
Dirty Moose

puntero en C

#include<stdio.h>
#include<stdlib.h>
main()
{
    int *p;
    p=(int*)calloc(3*sizeof(int));
    printf("Enter first number\n");
    scanf("%d",p);
    printf("Enter second number\n");
    scanf("%d",p+2);
    printf("%d%d",*p,*(p+2));
    free(p);
}
Busy Bat

estructura c con puntero

#include<stdio.h>
 
struct Point
{
   int x, y;
};
 
int main()
{
   struct Point p1 = {1, 2};
 
   // p2 is a pointer to structure p1
   struct Point *p2 = &p1;
 
   // Accessing structure members using structure pointer
   printf("%d %d", p2->x, p2->y);
   return 0;
}
Praveen

puntero en C

#include <stdio.h>
int main()
{
   int* pc, c;
   
   c = 22;
   printf("Address of c: %p\n", &c);
   printf("Value of c: %d\n\n", c);  // 22
   
   pc = &c;
   printf("Address of pointer pc: %p\n", pc);
   printf("Content of pointer pc: %d\n\n", *pc); // 22
   
   c = 11;
   printf("Address of pointer pc: %p\n", pc);
   printf("Content of pointer pc: %d\n\n", *pc); // 11
   
   *pc = 2;
   printf("Address of c: %p\n", &c);
   printf("Value of c: %d\n\n", c); // 2
   return 0;
}
Precious Pollan

Sintaxis del puntero C

int* p;
Friendly Fish

punteros c

#include <stdio.h>
int main()
{
   int *p;
   int var = 10;

   p= &var;

   printf("Value of variable var is: %d", var);
   printf("\nValue of variable var is: %d", *p);
   printf("\nAddress of variable var is: %p", &var);
   printf("\nAddress of variable var is: %p", p);
   printf("\nAddress of pointer p is: %p", &p);
   return 0;
}
#output
#Value of variable var is: 10
#Value of variable var is: 10
#Address of variable var is: 0x7fff5ed98c4c
#Address of variable var is: 0x7fff5ed98c4c
#Address of pointer p is: 0x7fff5ed98c50

Lil Uzi

Respuestas similares a “Punteros en c”

Preguntas similares a “Punteros en c”

Más respuestas relacionadas con “Punteros en c” en C++

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código