Tfw I know C but I can't into bash and regexps

>tfw I know C but I can't into bash and regexps
#include

int main(){
FILE *fp;
int i;
fp = fopen("./wdown.sh", "a");
fprintf(fp, "#!/bin/bash\n");
fclose(fp);
fp = fopen("./wdown.sh", "a");
fprintf(fp, "mkdir 4chanban\n");
fclose(fp);
fp = fopen("./wdown.sh", "a");
fprintf(fp, "cd 4chanban\n");
fclose(fp);
fp = fopen("./wdown.sh", "a");
for (i = 0; i < 251; i++) {
fprintf(fp, "wget s.4cdn.org/image/title/%u.png\n", i);
fclose(fp);
fp = fopen("./wdown.sh", "a"); }
for (i = 0; i < 252; i++) {
fprintf(fp, "wget s.4cdn.org/image/title/%u.gif\n", i);
fclose(fp);
fp = fopen("./wdown.sh", "a"); }
for (i = 0; i < 223; i++) {
fprintf(fp, "wget s.4cdn.org/image/title/%u.jpg\n", i);
fclose(fp);
fp = fopen("./wdown.sh", "a"); }
fclose(fp);
return 0;
}

>I know C
>closes and reopens the same file over 700 times for no reason
Is this bait?

>for no reason
Before I wrote 700 reopens, it gave me segfault.

>Is this bait?
And no, I'm legitimately retarded.

You're obviously doing something wrong, but it you actually "knew C" you should at least know enough to abstract "open, append, close" into its own function

I was too lazy too give out a function, vim macros did the work for me.

You could literally write a bash script for this and not use C.

Use:

for i in $(seq 1 255); do
echo $i
done

you're too busy thinking about being a girl and sucking cock to learn bash OP?

>thinking about being a girl
Nah, I'm just an ordinary faggot.

Not him, but
>Nah, I'm just an ordinary faggot.
>is a dude, not even pretending
>still wants dick
At least ur honest with urself, OP

>no line spacing
>one space tab

Not even the worst part about this code, but nevertheless, kill yourself.

Why didn't you print those strings to the file all at once rather than open and close it between each string?

Regardless, it's clear that you don't "know C".

>Why didn't you print those strings to the file all at once rather than open and close it between each string?
See >kill yourself
Who'll suck you the dick then?

>when I do x, a segfault doesn't happen
>therefore, x is the only thing that makes a segfault not happen

You're fucking retarded. Go back to the original code and actually work out why the segfault occurs. You probably fucked up a loop counter or something. Run it through gdb.

>who'll suck you the dick then
idk if he's THAT desperate user

Tbh I was desperate enough to become a yoga enthusiast :^)

I don't need no womyn.

You should put on some yoga pants and show me some positions

It's too late, just keep me the thread up if you want~

You'd be better off looking for a man to support you financially, don't get coding as a job~

Too late, I'm employed

quit it and work for me, i'll hire you under the table

>Go back to the original code and actually work out why the segfault occurs
I removed all fopen and fclose except of the first fopen and the last fclose and it worked with no issues. I have no idea why it worked.

it's a wonder ur employed, u must be sucking boss' cock

Then you've probably tried to access a null pointer or passed one as an argument.

Like I said, work out, in detail, what causes the segfault.

Show me the original code. You definitely can't be employed with such dreadful code lol

>Show me the original code.
It's lost.
>You definitely can't be employed with such dreadful code
I'm a web programmer :^)

>reopening the same file over and over again.

More like this, user:
#include

int main(){
FILE *fp;
int i;
fp = fopen("./wdown.sh", "a");
fprintf(fp, "#!/bin/bash\n"
"mkdir 4chanban\n"
"cd 4chanban\n");
for (i = 0; i < 251; i++) {
fprintf(fp, "wget s.4cdn.org/image/title/%u.png\n", i);
}
for (i = 0; i < 252; i++) {
fprintf(fp, "wget s.4cdn.org/image/title/%u.gif\n", i);
}
for (i = 0; i < 223; i++) {
fprintf(fp, "wget s.4cdn.org/image/title/%u.jpg\n", i);
}
fclose(fp);
return 0;
}

One open.
One close.

You have clearly failed at C.

Also, you could just use a proper scripting language, like Ruby or Python...

This is why I left Cred Forums

The cs degree meme is everywhere