Linux Quiz #002

The Patch Command (submit answer)

Create a patch file called helloworld.patch suitable for use with the
patch command to fix a typo in helloworld.c. Also, give the command line necessary to apply the patch.

To test the syntax of the .c file use: gcc -o helloworld helloworld.c

helloworld.c

2 Responses to “Linux Quiz #002”

  1. To create the specified patch without getting into the all the mumbo jumbo about standards.
    The quick and gritty..
    cp helloworld.c helloworld_pre_patch.c
    vi hello_world_pre_patch.c
    make corrections, in this case move the out of place ! to where it needs to be.
    old char* msg = “Hello World”!;
    new char* msg = “Hello World!”;
    esc :wq
    diff -uN helloworld.c helloworld_pre_patch.c >helloworld.patch
    rm helloworld_pre_patch.c

    To patch

    patch helloworld.c h.patch

  2. Minor typo:
    patch helloworld.c < helloworld.patch