标签归档:C

互联网应用 Lab

Lab 3

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

int main() {
    char *arg[] = {"/bin/ls", 0};

    /* fork, and exec within child process */
    if (fork() == 0) {
        printf("In child process:\n");
        execv(arg[0], arg);
        printf("I will never be called\n");
    }

    printf("Execution continues in parent process\n");

    return 0;
}

继续阅读

Coursework 2015

Question

Write a program that will help elementary school pupils practice math.

a) The program will first ask the user for his/her ID number (including two letters & 4 digits), e.g.:

Please input your four digit ID no: AB1234
The program should have input validation.
Then the program prompts three choices:
* Start a test
* Check scores
* Exit
继续阅读