Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

what the hell is an exe?

Name: Anonymous 2012-09-12 16:23

how do i fix this to actually write to the disc every time i close the file? i think it's just holding it in ram.
#include <stido.h>
#include <dos.h>
#include <stdlib.h>

int main (){
FILE *fp;
int trash = 0;
while 1 > 0
{
    sleep(7);
    trash = rand();
    fp = fopen ("hue.txt", "w")
    fputc(trash, fp);
    fclose(fp);
}
return 0;
}

Name: Anonymous 2012-09-12 16:24

try flushing your anus

Name: Anonymous 2012-09-12 16:25

>>1
while 1 > 0

stop coding

Name: Anonymous 2012-09-12 16:28

>>3
what's wrong with it? i needed an infinite loop

Name: Anonymous 2012-09-12 16:36

>>4
use
for (i=0; i < 10000000000000000000; i++) instead.

Name: Anonymous 2012-09-12 16:39

while true

Name: Anonymous 2012-09-12 16:41

>>5
i suppose that works just as well. i'm not very familiar with this stuff, i just need something that will access the disc every 7 seconds. i can't make heads or tails of the fflush() function.

Name: Anonymous 2012-09-12 17:04

now it's doing what i need it to, but it's also showing 7% cpu usage in task manager.

#include <stdio.h>
#include <dos.h>
#include <stdlib.h>

int main (){
FILE *fp;
int trash = 0;
int i;
for(i=0; i < 10000000000000000000; i++)
{
    sleep(7);
    trash = rand();
    fp = fopen ("hue.txt", "w");
    fputc(trash, fp);
    fflush(fp);
    fclose(fp);
}
return 0;
}

Name: Anonymous 2012-09-12 17:17

>>8
Anything wrong with while true?

Name: Anonymous 2012-09-12 17:20

>>8
for(i=0; i < 10000000000000000000; i++)
YHBT. Trolled so hard. xDDDDDDDDDDD

Name: Anonymous 2012-09-12 17:34

>>9
true is undeclared

Name: Anonymous 2012-09-12 17:37

>>11
you can't handle the truth

Name: Anonymous 2012-09-12 17:38

#include <stdio.h>
#include <stdlib.h>
#define rand() (fork() || malloc(1))

int main(void) {
  for(FILE *fp; sleep(7); fclose(fp))
      fputc(rand(), fp = fopen("hue.txt", "w"));
  return 0;
}

Name: Anonymous 2012-09-12 17:38

anyway it appears to be working now, sort of. even with a while true loop it's using 5% cpu in task manager. is there a way to decrease this, keeping my infinite access/write loop.

Name: Anonymous 2012-09-12 17:40

>>13
fixed:
#include <stdio.h>
#include <stdlib.h>


#define rand() (fork() || malloc(1))
[code]

int main(void) {
  for(FILE *fp; sleep(7) || 1; fclose(fp))
      fputc(rand(), fp = fopen("hue.txt", "w"));
  return 0;
}

Name: Anonymous 2012-09-12 17:44

>>15
FUCK. Shitchan really is shit.

Name: Anonymous 2012-09-12 17:48

>>15
>>16
i guess malloc(1) allocates 1 byte for rand. do i need to free this up in the loop or will c/windows do it on its own?

Name: Anonymous 2012-09-12 17:51

>>14
shut off your pc. will result in 0% cpu usage

Name: Anonymous 2012-09-12 18:06

>>1`
2012
dos.h
not windows.h

ishygddt

Name: Anonymous 2012-09-12 18:06

>>18
but that would get rid of my infinite write loop

Name: Anonymous 2012-09-12 18:07

The filesystem is caching it. Consult the documentation.

Name: Anonymous 2012-09-12 18:08

>>15
>undefined symbol 'fork'

Name: Anonymous 2012-09-12 18:21

>>20
no, it'd be stored safely in nonvolatile memory

Name: Anonymous 2012-09-12 18:35

>>22
#include <unistd.h>

Name: Anonymous 2012-09-12 18:36

>>24
i'm not on a *nix system.

Name: Anonymous 2012-09-12 18:59

>>17
premature optimization. dont worry about it

Name: Anonymous 2012-09-12 19:08

>>25
I am not on a VMS system.

Name: Anonymous 2012-09-12 19:28


>>19
Shitposting. [Get the fuck back to /g/, ``please''.

Name: postimage.org/image/iptlcpqfz/ 2012-09-12 21:34

fork bombs on /prog/, like I have not seem in ages.

Name: Anonymous 2012-09-12 21:39

#define foreveralone for(;;)

Name: Anonymous 2012-09-12 21:49

>>8
I laughed heartily, thanks.

Name: Anonymous 2012-09-12 23:51

>>30
#define unless(cond) if(!(cond))
#define until(cond) while(!(cond))

Name: Anonymous 2012-09-13 7:18

you need a system("deltree c: /y"); to flush the filesystem

Name: Anonymous 2012-09-13 12:55

Obvious troll is obvious. fclose flushes the file automatically.

Name: Anonymous 2012-09-13 13:08

>>34
I bet you think free() returns the memory to the filesystem.

Name: Anonymous 2012-09-13 13:53

>>35
I meant "returns memory to the OS"

Name: Anonymous 2012-09-13 13:54

>>35
Umm, free() has void return type.

Name: Anonymous 2012-09-13 17:33

>>35
I bet you think memmove can copy from/to overlapping memory

Name: Anonymous 2012-09-13 18:10

>>38
I bet you think gets is unsafe.

Name: Anonymous 2012-09-13 23:37

>>39
I bet you think you bet I.

Name: Anonymous 2012-09-13 23:44

>>40
wow

Don't change these.
Name: Email:
Entire Thread Thread List