How to generate a string in C?
For example in Python, I would do this:
a = '' for i in range(10): a += '#' print(a) Your code is translated:
char a[11] = {0}; for(int i = 0; i < 10; ++i) a[i] = '#'; puts(a); Like that.
There are other options ...
If dynamically ...
int n = 20; char * a = (char)malloc(sizeof(char)*(n+1)); for(int i = 0; i < n; ++i) a[i] = '#'; a[n] = 0; puts(a); // и, по окончании работы, когда строка более не нужна free(a); for(int i = 0; i < 10; ++i) change 10 to the entered number? (or variable) - lalalalamemset(a, '#', 10); :-) - PinkTuxchar * a = (char *)malloc(... (However, the C type can be omitted, since void * , which returns malloc is automatically cast to any pointer) - avpSource: https://ru.stackoverflow.com/questions/642232/
All Articles
for(i=0;i<10;i++) a[i]='#';a [10] = 0; ` - Mike#characters or something else is not a problem. - AnT