A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C program to create memory for int, char and float variable at run time.
Q:

C program to create memory for int, char and float variable at run time.

-1

C program to create memory for int, char and float variable at run time.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

/*C program to create memory for int, 
char and float variable at run time.*/
 
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int *iVar;
    char *cVar;
    float *fVar;
     
    /*allocating memory dynamically*/
     
    iVar=(int*)malloc(1*sizeof(int));
    cVar=(char*)malloc(1*sizeof(char));
    fVar=(float*)malloc(1*sizeof(float));
     
    printf("Enter integer value: ");
    scanf("%d",iVar);
     
    printf("Enter character value: ");
    scanf(" %c",cVar);
     
    printf("Enter float value: ");
    scanf("%f",fVar);
     
    printf("Inputted value are: %d, %c, %.2f\n",*iVar,*cVar,*fVar);
     
    /*free allocated memory*/
    free(iVar);
    free(cVar);
    free(fVar);
 
    return 0;
}
    Enter integer value: 100
    Enter character value: x
    Enter float value: 123.45
    Inputted value are: 100, x, 123.45

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now