#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void f(char *, int);
int main(void)
{
char hoge[10];
f
(hoge
, strlen(hoge
)); //文字列と \0を除く文字数 return 0;
}
void f(char *hoge, int len)
{
char *pp
= (char *) malloc(sizeof(char) * (len
+ 1)); int i;
char b = '\0';
if (pp == NULL) {
return;
} else {
*(pp + len) = b;
for (i = 0; i < len; i++) {
*(pp + i) = hoge[i];
}
}
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RyaW5nLmg+CiNpbmNsdWRlPHN0ZGxpYi5oPgoKdm9pZCBmKGNoYXIgKiwgaW50KTsKCmludCBtYWluKHZvaWQpCnsKICAgIGNoYXIgaG9nZVsxMF07CiAgICBzY2FuZigiJTlzIiwgaG9nZSk7CiAgICBmKGhvZ2UsIHN0cmxlbihob2dlKSk7ICAgICAgLy/mloflrZfliJfjgaggXDDjgpLpmaTjgY/mloflrZfmlbAKICAgIHJldHVybiAwOwp9Cgp2b2lkIGYoY2hhciAqaG9nZSwgaW50IGxlbikKewogICAgY2hhciAqcHAgPSAoY2hhciAqKSBtYWxsb2Moc2l6ZW9mKGNoYXIpICogKGxlbiArIDEpKTsKICAgIGludCBpOwogICAgY2hhciBiID0gJ1wwJzsKICAgIGlmIChwcCA9PSBOVUxMKSB7CiAgICAgICAgcHJpbnRmKCJtZW1vcnllcnJvclxuIik7CiAgICAgICAgcmV0dXJuOwogICAgfSBlbHNlIHsKICAgICAgICAqKHBwICsgbGVuKSA9IGI7CiAgICAgICAgZm9yIChpID0gMDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgICoocHAgKyBpKSA9IGhvZ2VbaV07CiAgICAgICAgfQogICAgICAgIHByaW50ZigiJXNcbiIsIHBwKTsKICAgIH0KICAgIGZyZWUocHApOwp9Cg==