Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
challoc
/* test sort an array */ #include <stdio.h> #include <string.h> /* challoc works like malloc, but from static area. Do not free. calling with sz = 0 will free everything and start over */ void *challoc(int sz){ // set aside a static buffer static char mem[BUFSIZ]; static int idx, last; if (!(sz)) return(idx=0, NULL); // allocate from static area last = idx, idx += sz; if(idx > BUFSIZ) return NULL; else return &mem[last];} char *st4dup(char *s){ return strcpy(challoc(strlen(s)+1), s);} int main(int argc, char **argv, char** env){ char *j = st4dup("hello"); if(j) puts(j); char *p = st4dup("there"); if(p) puts(p); return 0; }
run
|
edit
|
history
|
help
0
Multiple If statements v.09
Spring 2017 Project 2 v.02
Lab 11 v.05
a1
Float data type.c
Exploiting uninitialized variable 2
part2final
Stub Program for Problem 5 HW 2
String Manipulation
Atomic Openmp