C
Chad
I just can't sit down and watch TV or go to the local bar and talk
about what I've done on my days off with the locals. With that.....
Is the following valid?
m-net% more mall.c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main(void)
{
char a = 5;
char *p;
if((p = malloc(sizeof a)) == NULL ){
fprintf(stderr, "Can't allocate memory\n");
}
free(p);
if(p =! NULL){
printf("Memory has been freed\n");
}
return 0;
}
m-net% gcc -Wall mall.c -o mall
mall.c: In function `main':
mall.c:16: warning: assignment makes pointer from integer without a
cast
mall.c:16: warning: suggest parentheses around assignment used as
truth value
m-net% ./mall
Memory has been freed
m-net%
about what I've done on my days off with the locals. With that.....
Is the following valid?
m-net% more mall.c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main(void)
{
char a = 5;
char *p;
if((p = malloc(sizeof a)) == NULL ){
fprintf(stderr, "Can't allocate memory\n");
}
free(p);
if(p =! NULL){
printf("Memory has been freed\n");
}
return 0;
}
m-net% gcc -Wall mall.c -o mall
mall.c: In function `main':
mall.c:16: warning: assignment makes pointer from integer without a
cast
mall.c:16: warning: suggest parentheses around assignment used as
truth value
m-net% ./mall
Memory has been freed
m-net%