[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: idwojqijd.gif (1.46 MB, 498x372)
1.46 MB
1.46 MB GIF
someone told me to run this on my pc , what does it do?
#include <stdio.h>
#include <stdlib.h>

void write_program() {
FILE *file = fopen("generated_program.c", "w");
if (file == NULL) {
printf("Erre.\n");
return;
}

const char *program_code =
"#include <stdio.h>\\n"
"#include <stdlib.h>\\n"
"\\n"
"void create_files_safely() {\\n"
" int counter = 0;\\n"
" char filename[50];\\n"
" while (counter < 10) {\\n"
" sprintf(filename, \\\"sfe_file_%%d.txt\\\", counter);\\n"
" FILE *file = fopen(filename, \\\"w\\\");\\n"
" if (file != NULL) {\\n"
" fclose(file);\\n"
" }\\n"
" counter++;\\n"
" }\\n"
"}\\n"
"\\n"
"int main() {\\n"
" printf(\\\"Ces...\\n\\\");\\n"
" create_files_safely();\\n"
" return 0;\\n"
"}\\n";

fprintf(file, "%s", program_code);
fclose(file);
}

int main() {
printf("Generating program...\n");
write_program();
printf("Generated program written to 'generated_program.c'.\n");

int compile_result = system("gcc -o generated_program generated_program.c");
if (compile_result == 0) {
printf("C.\n");

// Run the compiled program
int run_result = system("./generated_program");
if (run_result == 0) {
printf("Ge.\n");
} else {
printf("Erro.\n");
}
} else {
printf("Errm.\n");
}

return 0;
}
>>
>>101560344
makes 10 files for no reason then exits
>>
>>101560344
Generate 10 text files
>>
File: 1716205596191950.jpg (35 KB, 716x624)
35 KB
35 KB JPG
>>101560577
>sfe_file_%%d.txt
Oh wait anon there is something wrong about this, don't run, if i'm not wrong sfe here stands for slipt file extension, this thing will mess with your os shell, i strongly recommend you to avoid running it, if you want to try it run it in a VM, the txt at the end is misleading
>>
>>101560344
Was this "someone" named ChatGPT?
>>
>>101560640
how did u know



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.