I have a function that makes a string with a certain number of #. String is stored as in char array (at list I think this is it... I'm new to C). This string is generated inside a function called blocks. I want to know how to return it so I can display it with printf("Someting Something %s", bricks)
Do I have to change data type of ma string to char or how do I change the code to work?
int main(void)
{
char hashes = blocks(3);
}
char blocks(int n)
{
// string in which I will store data
char line[] = "";
int max = n + 1;
for (int i = 0; i < max; i++)
{
// n times # is appended to char array line
char brick[] = "#";
strcat(line, brick);
}
return line;
}
I want to know how to return string or array ###
and store it in variable hashes.