0

Say i have an

int c =8;

and i want to do a fork to say do a printf

printf("hello im number blah blah");

is there a way to do that printf as many times as whatever c is equal too?
using a fork().

maybe something like

int pid;
pid=fork(c)
printf("hello im number blah blah");
3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by gerard4143
0

Here's a very simple example:

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

int main(int argc, char**argv)
{
	int i = 0;
	for (i = 0; i < 5; ++i)
	{
		if (fork())
		{
	
		}
		else
		{
			fputs("Hello, World!\n", stdout);
			exit(EXIT_SUCCESS);	
		}
	}
	exit(EXIT_SUCCESS);
}
0

Like using a for loop perhaps?

I dont think i for loop would do it.

from what i wrote above i would want to printf the quoute the number of times c is equal to, so 8 times. im not aware i can do a for loop for this???

unlesssss
i do a

int c = 8;
int i = 0;

while( i <= c)
{
printf("kdjfjfjfkf");
i++;
}

that would work wouldnt it ??

0

that would work wouldnt it ??

Yes that wouldn't work, wouldn't it...

Edited by gerard4143: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.