Change Pseudo Code to C Program (print and fork)


 
Thread Tools Search this Thread
Top Forums Programming Change Pseudo Code to C Program (print and fork)
# 1  
Old 11-11-2009
Change Pseudo Code to C Program (print and fork)

I am very new at programming and this is probably an easy question, but I am desperate. I need to change this low level code into a C program that I can run so I can print out every "A" that appears with the fork() command. You help is greatly appreciated.
Code:
	PRINT A
	p=fork()
	if( p == 0) {
		PRINT A
		PRINT A
		fork()
		PRINT A
		fork()
	}
	else {
		LOOP_TWICE
			PRINT A
			fork()
			fork()
			PRINT A
		END_LOOP
		PRINT A
		fork()
	}
	PRINT A
	fork()
	PRINT A

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

How forbid use fork() in exec() program.

Hello World! I am writing code in C++ which have to launch another application X using exec(). I would like to set some limits on it using setrlimit etc... My problem is that i don't know how to forbid using fork() and strlimit by application X. How can i do it? (3 Replies)
Discussion started by: kzi
3 Replies

2. Linux

May you explain step by step where and how I will add pseudo code

Thank all of you. May you explain step by step where and how I will add pseudo code Note : I have Linux 2.6.24-26-server on x86_64 dears kindly help me (3 Replies)
Discussion started by: nonowa
3 Replies

3. Shell Programming and Scripting

Run shell script from C program by calling fork and execl

I need to write a c program that uses the fork and excel system calls to run the shell script mode invoked like this: "./mode 644 ls -l" (that is the argumetns will always be 644 ls -l) here's the mode script: #!/bin/sh octal="$1" shift find . -maxdepth 1 -perm $octal -exec $@ {} \; ... (3 Replies)
Discussion started by: computethis
3 Replies

4. Homework & Coursework Questions

Please help with the following fork code..with complete explanation

I have the following piece of codes. Please explain it to me in great detail how are these codes working. 1. #include <stdio.h> int main(){ int x; x=0; while (x<2 && fork()){ if (!fork()) execlp("echo","x++","x",0); x++; system("echo x+x"); } } 2. #include <stdio.h> int i;... (1 Reply)
Discussion started by: prakashabii
1 Replies

5. Programming

fork() and the program is hanging...

Consider the following code.. #include <unistd.h> #include <sys/types.h> #include <errno.h> #include <stdio.h> #include <sys/wait.h> #include <stdlib.h> int main() { pid_t childpid; int retval; int status; childpid = fork(); if(childpid >= 0) { ... (4 Replies)
Discussion started by: lipun4u
4 Replies

6. Shell Programming and Scripting

how to write pseudo code

hi, I'm doing some project, I selected shell script as programming language, I need to write pseudo code for my script, can anyone tell me how to write that.......?:) (1 Reply)
Discussion started by: hanaveenkumar
1 Replies

7. Shell Programming and Scripting

pseudo code needs help coding

Thanks in advance!!! Can I get someone to write this small script or can you direct me to a web link, etc. to get it done? --------- Initiate this script every 15 - 20 secs or so through cron. Gather LAN users' $info(username, mac or ipaddr, PID) OBJECT: Tie each username to a mac or ipaddr,... (6 Replies)
Discussion started by: tuxhats
6 Replies

8. Shell Programming and Scripting

Pseudo code or description

hi I need a Pseudo code or a description of what a program is saying from this spec and code: Just so i can understand how this solution was achieved, thanks here is the spec: Specifications are as follows:- The books records are stored in one csv file and the layout and the contents... (7 Replies)
Discussion started by: ferrycorsten73
7 Replies

9. Programming

C++ How to use pipe() & fork() with stdin and stdout to another program

Hi, Program A: uses pipe() I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using: * child -> dup2(fd, STDOUT_FILENO); -> execl("/path/PROGRAM B", "PROGRAM B", NULL); * parent -> char line; -> read(fd, line, 100); Question:... (2 Replies)
Discussion started by: vvaidyan
2 Replies

10. Solaris

pseudo: [ID 129642 kern.info] pseudo-device: vol0

Hi I have a system that gave me some messages on bootup that I was not used to seeing: pseudo: pseudo-device: vol0 genunix: vol0 is /pseudo/vol@0 these came with these: Feb 13 17:42:17 system1 eri: SUNW,eri0 : 100 Mbps full duplex link up Feb 13 17:42:21 system1sendmail: My unqualified... (0 Replies)
Discussion started by: mndavies
0 Replies
Login or Register to Ask a Question
uuid(3pm)						User Contributed Perl Documentation						 uuid(3pm)

NAME
OSSP::uuid - OSSP uuid Perl Binding DESCRIPTION
OSSP uuid is a ISO-C:1999 application programming interface (API) and corresponding command line interface (CLI) for the generation of DCE 1.1, ISO/IEC 11578:1996 and RFC 4122 compliant Universally Unique Identifier (UUID). It supports DCE 1.1 variant UUIDs of version 1 (time and node based), version 3 (name based, MD5), version 4 (random number based) and version 5 (name based, SHA-1). Additional API bindings are provided for the languages ISO-C++:1998, Perl:5 and PHP:4/5. Optional backward compatibility exists for the ISO-C DCE-1.1 and Perl Data::UUID APIs. OSSP::uuid is the Perl binding to the OSSP uuid API. Three variants are provided: TIE-STYLE API The TIE-style API is a functionality-reduced wrapper around the OO-style API and intended for very high-level convenience programming: "use OSSP::uuid;" tie" my $uuid, 'OSSP::uuid::tie', $mode, ...;" "$uuid = [ $mode, ... ];" "print "UUID=$uuid ";" "untie $uuid;" OO-STYLE API The OO-style API is a wrapper around the C-style API and intended for high-level regular programming. "use OSSP::uuid;" "my $uuid = "new" OSSP::uuid;" "$uuid->"load"($name);" "$uuid->"make"($mode, ...);" "$result = $uuid->"isnil"();" "$result = $uuid->"compare"($uuid2);" "$uuid->"import"($fmt, $data_ptr);" "$data_ptr = $uuid->"export"($fmt);" "[(]$str[, $rc)] = $uuid->"error"();" "$ver = $uuid->"version"();" "undef $uuid;" Additionally, the strings "v1", "v3", "v4", "v5" and "mc" can be used in $mode and the strings "bin", "str", and "txt" can be used for $fmt. C-STYLE API The C-style API is a direct mapping of the OSSP uuid ISO-C API to Perl and is intended for low-level programming. See uuid(3) for a description of the functions and their expected arguments. "use OSSP::uuid qw(:all);" "my $uuid; $rc = "uuid_create"($uuid);" "$rc = "uuid_load"($uuid, $name);" "$rc = "uuid_make"($uuid, $mode, ...);" "$rc = "uuid_isnil"($uuid, $result);" "$rc = "uuid_compare"($uuid, $uuid2, $result);" "$rc = "uuid_import"($uuid, $fmt, $data_ptr, $data_len);" "$rc = "uuid_export"($uuid, $fmt, $data_ptr, $data_len);" "$str = "uuid_error"($rc);" "$ver = "uuid_version"();" "$rc = "uuid_destroy"($uuid);" Additionally, the following constants are exported for use in $rc, $mode, $fmt and $ver: "UUID_VERSION", "UUID_LEN_BIN", "UUID_LEN_STR", "UUID_RC_OK", "UUID_RC_ARG", "UUID_RC_MEM", "UUID_RC_SYS", "UUID_RC_INT", "UUID_RC_IMP", "UUID_MAKE_V1", "UUID_MAKE_V3", "UUID_MAKE_V4", "UUID_MAKE_V5", "UUID_MAKE_MC", "UUID_FMT_BIN", "UUID_FMT_STR", "UUID_FMT_SIV", "UUID_FMT_TXT". EXAMPLES
The following two examples create the version 3 UUID "02d9e6d5-9467-382e-8f9b-9300a64ac3cd", both via the OO-style and the C-style API. Error handling is omitted here for easier reading, but has to be added for production-quality code. # TIE-style API (very high-level) use OSSP::uuid; tie my $uuid, 'OSSP::uuid::tie'; $uuid = [ "v1" ]; print "UUIDs: $uuid, $uuid, $uuid "; $uuid = [ "v3", "ns:URL", "http://www.ossp.org/" ]; print "UUIDs: $uuid, $uuid, $uuid "; untie $uuid; # OO-style API (high-level) use OSSP::uuid; my $uuid = new OSSP::uuid; my $uuid_ns = new OSSP::uuid; $uuid_ns->load("ns:URL"); $uuid->make("v3", $uuid_ns, "http://www.ossp.org/"); undef $uuid_ns; my $str = $uuid->export("str"); undef $uuid; print "$str "; # C-style API (low-level) use OSSP::uuid qw(:all); my $uuid; uuid_create($uuid); my $uuid_ns; uuid_create($uuid_ns); uuid_load($uuid_ns, "ns:URL"); uuid_make($uuid, UUID_MAKE_V3, $uuid_ns, "http://www.ossp.org/"); uuid_destroy($uuid_ns); my $str; uuid_export($uuid, UUID_FMT_STR, $str, undef); uuid_destroy($uuid); print "$str "; SEE ALSO
uuid(1), uuid-config(1), uuid(3). HISTORY
The Perl binding OSSP::uuid to OSSP uuid was implemented in November 2004 by Ralf S. Engelschall <rse@engelschall.com>. perl v5.14.2 2007-01-01 uuid(3pm)