fork() + newbie


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers fork() + newbie
# 1  
Old 04-14-2010
fork() + newbie

Hey

I'm new, as you might have guessed :P

I have a school assignment that involves fork(), and im not gonna ask for the solution but WHERE to actually write the code..

I'm suppose to make a program, where the assignment itself is not really important but I cant seem to find the right compiler or what else to make this work.

Netbeans, whines about it cant find this and that, it doesnt even know what iostream is O_o..
Dev cant find anything related with fork..
BlueJ have no clue what fork is..

Before you start, you're suppose to learn about Unix processes and alittle about how to use some compiler called "Vi" by going through the putty.exe terminal. Which itself is a nightmare, not really but close :P

Am I suppose to use the Vi compiler or does any program work? I'm not sure but I think this might be the only Unix based assignment we will have and its very little information, maybe I have the wrong litterature, I dont know..

Ive written alittle code already, of course its far from finished since I have no clue about Unix and fork-ing.. and YES that is Java class code,
not that modifying it so it should have worked with C++, made a difference..

Well, didnt I write a short story..

What I need help with is understanding how the world of Unix works since I've never crossed over to the other side :P

Edit:
Oh, you are suppose to name school, teacher info:
Gotland University (Advanced Webbprogramming, 3 years), Sweden, Europe, Tellus :P
Håkan something, cant check his surname right now because of site loginproblems..

Last edited by 1st_maza; 04-14-2010 at 09:49 PM..
# 2  
Old 04-14-2010
vi is an editor. cc is a compiler for c programs
This is a C program
Code:
#include <stdio.h>
/* filename = myprog.c */
int main(void)
{

   printf("Hello world\n");
   return 0;
}

This compiles and runs a C program called myprog.c
Code:
> cc myprog.c -o myprog
> ./myprog
Hello world
>

You should post homework in the homework forum.
I'm going to close this thread. If you want more homework help please post there.

As a general comment, you seem very confused about things in your class.
fork() creates a child process, which is an independent standalone copy of the parent process.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Fork!

I understand that fork create a child but I need very simple example that make child useful.... I mean how will make the program faster anyone explain with code plz using C plz (2 Replies)
Discussion started by: fwrlfo
2 Replies

2. Programming

Newbie question on exec,fork, wait,pipe C

Hello everybody.I want to make clear that i am not going to ask from anybody to build my asignement but i have a big problem. I can't seem to find anywhere ONE good example on C about what i am trying to do:wall:.I think it is simple. All i ask is one example, even a link is fine. So, i want to... (1 Reply)
Discussion started by: Cuervo
1 Replies

3. Shell Programming and Scripting

perl newbie . &&..programming newbie

Hi, I am new to programming and also to perl..But i know 'perl' can come to my rescue, But I am stuck at many places and need help..any small help is much appreciated... below is the description of what i intend to acheive with my script. I have a files named in this format... (13 Replies)
Discussion started by: xytiz
13 Replies

4. Shell Programming and Scripting

perl newbie . &&..programming newbie (question 2)

Hello everyone, I am having to do a lot of perl scripting these days and I am learning a lot. I have this problem I want to move files from a folder and all its sub folders to one parent folder, they are all .gz files.. there is folder1\folder2\*.gz and there are about 50 folders... (1 Reply)
Discussion started by: xytiz
1 Replies

5. UNIX for Dummies Questions & Answers

UNIX newbie NEWBIE question!

Hello everyone, Just started UNIX today! In our school we use solaris. I just want to know how do I setup Solaris 10 not the GUI one, the one where you have to type the commands like ECHO, ls, pwd, etc... I have windows xp and I also have vmware. I hope I am not missing anything! :p (4 Replies)
Discussion started by: Hanamachi
4 Replies

6. Programming

Fork and \n

Hi, I wrote a simple program for understanding the fork command. The code is as below int main(void) { fork(); printf("hi 1 \n"); fork(); printf("hi 2 \n"); fork(); printf("hi 3 \n"); } I am getting a variation in the number of times the printf is called if i remove the \n from each... (2 Replies)
Discussion started by: xyz123456
2 Replies

7. UNIX for Advanced & Expert Users

Fork and \n

Hi, I wrote a simple program for understanding the fork command. The code is as below int main(void) { fork(); printf("hi 1 \n"); fork(); printf("hi 2 \n"); fork(); printf("hi 3 \n"); } I am getting a variation in the number of times the printf is called if i remove the \n from each of... (1 Reply)
Discussion started by: xyz123456
1 Replies

8. Programming

Fork or what?

Hello all. I'm developing a filetransfer application, which is supposed to work sort of like dcc, with multiple transfers etc. Now i wonder what the best way to manage the transfers is. Should i fork() for each new transfer, hogging loads of memory or use pthreads? Maybe I can use select to see... (0 Replies)
Discussion started by: crippe
0 Replies

9. Programming

fork()

#include <stdio.h> #include <string.h> #include <sys/types.h> #define MAX_COUNT 200 #define BUF_SIZE 100 void main(void) { pid_t pid; int i; char buf; fork(); pid = getpid(); for (i = 1; i <= MAX_COUNT; i++) { sprintf(buf,... (2 Replies)
Discussion started by: MKSRaja
2 Replies

10. Programming

fork() fd

I run this code, actually I want to both processes print the message from "data". But only one does. What happens? Anyone can help? #include <stdio.h> main(){ int fd, pid; char x; fd = open("data",0); /* open file "data" */ pid = fork(); if(pid != 0){ wait(0); ... (2 Replies)
Discussion started by: Herman
2 Replies
Login or Register to Ask a Question