Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/Repeat-a-string/C/repeat-a-string-3.c
Normal file
17
Task/Repeat-a-string/C/repeat-a-string-3.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char * char_repeat( int n, char c ) {
|
||||
char * dest = malloc(n+1);
|
||||
memset(dest, c, n);
|
||||
dest[n] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
int main() {
|
||||
char * result = char_repeat(5, '*');
|
||||
puts(result);
|
||||
free(result);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue