Answer the question
In order to leave comments, you need to log in
How to port JS code to C, what am I doing wrong?
Is it possible to transfer this from JS to C?
for (var line = "#"; line.length < 7; line += "#") {
console.log(line);
Like
for(char line="#"; line.length<7; line+="#"){
printf("%d",line);
}
You need to line up something like:
#
##
###
####
#####
######
#######
Answer the question
In order to leave comments, you need to log in
In pure C, there are no dynamic strings, only numeric variables, pointers (references), structures, and fixed size arrays. The closest to JS code, but also the most crooked, will be the following code:
char line[8];
*line = 0;
for(strcat(line, "#"); strlen(line) < 7; strcat(line, "#"))
puts(line);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question