K
kernel.lover
hello,
why following is not working in c program?
#include <unistd.h>
#include <stdlib.h>
#define ONE_K (1024)
int main() {
char *some_memory;
char *scan_ptr;
some_memory = (char *)malloc(ONE_K);
if (some_memory == NULL) exit(EXIT_FAILURE);
scan_ptr = some_memory;
while(1) {
*scan_ptr = 'p'; //problem statement
scan_ptr++;
}
exit(EXIT_SUCCESS);
}
Also in following program what should be correct assignment to *some_memory ???
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
//char *some_memory = (char *)0;
char *some_memory = "\0";
printf("A read from null %s\n", some_memory);
sprintf(some_memory, "A write to null\n");
exit(EXIT_SUCCESS);
}
why following is not working in c program?
#include <unistd.h>
#include <stdlib.h>
#define ONE_K (1024)
int main() {
char *some_memory;
char *scan_ptr;
some_memory = (char *)malloc(ONE_K);
if (some_memory == NULL) exit(EXIT_FAILURE);
scan_ptr = some_memory;
while(1) {
*scan_ptr = 'p'; //problem statement
scan_ptr++;
}
exit(EXIT_SUCCESS);
}
Also in following program what should be correct assignment to *some_memory ???
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
//char *some_memory = (char *)0;
char *some_memory = "\0";
printf("A read from null %s\n", some_memory);
sprintf(some_memory, "A write to null\n");
exit(EXIT_SUCCESS);
}