>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; }
Alexander Gomez
>I know C >closes and reopens the same file over 700 times for no reason Is this bait?
Juan Robinson
>for no reason Before I wrote 700 reopens, it gave me segfault.
Robert Nguyen
>Is this bait? And no, I'm legitimately retarded.
Joseph Mitchell
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
Aaron Williams
I was too lazy too give out a function, vim macros did the work for me.
Nathan Thompson
You could literally write a bash script for this and not use C.
Use:
for i in $(seq 1 255); do echo $i done
Caleb Sullivan
you're too busy thinking about being a girl and sucking cock to learn bash OP?
Liam Campbell
>thinking about being a girl Nah, I'm just an ordinary faggot.
Angel Wright
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
Ian Campbell
succ me
Jason Adams
>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".
Nathan Ross
>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?
Elijah Taylor
>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.
Isaac Ward
>who'll suck you the dick then idk if he's THAT desperate user
Jordan Miller
Tbh I was desperate enough to become a yoga enthusiast :^)
I don't need no womyn.
Elijah Scott
You should put on some yoga pants and show me some positions
Hunter Carter
It's too late, just keep me the thread up if you want~
Julian Mitchell
You'd be better off looking for a man to support you financially, don't get coding as a job~
Jason Moore
Too late, I'm employed
Juan Miller
quit it and work for me, i'll hire you under the table
Hudson Anderson
>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.
Christian Davis
it's a wonder ur employed, u must be sucking boss' cock
Grayson Howard
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
Joshua Miller
>Show me the original code. It's lost. >You definitely can't be employed with such dreadful code I'm a web programmer :^)
Jaxon Collins
>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...