Banned functions in CS3214§

The following C functions are banned in all assignments and exams in CS3214:

  • strcpy
  • strcat
  • strncpy
  • strncat
  • sprintf
  • vsprintf
  • fscanf("%s", ...), scanf("%s", ...), or sscanf with the "%s" modifier.

Reimplementations of banned functions§

Reimplementations of banned functions are also not permitted, as is the use of memcpy in attempts to reimplement them.

For example, code such as this:

    char* final = calloc(500, sizeof(char));

    int index = 0;
    final[index++] = '@';
    memcpy(final + index, host, strlen(host));
    index += strlen(host);

    final[index++] = ' ';
    final[index++] = 'i';
    final[index++] = 'n';
    final[index++] = ' ';

    memcpy(final + index, lastpwd, strlen(lastpwd));
    index += strlen(lastpwd);

    final[index++] = ']';
    final[index++] = ' ';

falls under this category.

Allowed functions in CS3214§

To preempt and answer questions such as "is function xyz" allowed, here is our baseline policy. You may use all C functionality and functions that are

  • part of the ISO C Standard in the revision that's activated by default for the version of gcc installed on rlogin (currently gcc 11.5 which I believe is C17.), and/or
  • a GNU extension, and/or
  • part of POSIX and/or
  • installed on rlogin.

In addition, the function must

  • not be generally banned as described earlier in this document, and
  • not be specifically banned for an assignment (i.e., when implementing malloc you obviously cannot use malloc).

This means that in general, if a function is available, you may use it unless specifically prohibited.

When using a function, you must include the headers as stated in its man page. For example, if you want to use the system call/function pipe2, consult its man page, which has:

       #define _GNU_SOURCE             /* See feature_test_macros(7) */
       #include <fcntl.h>              /* Definition of O_* constants */
       #include <unistd.h>

       int pipe2(int pipefd[2], int flags);

and you literally need to define _GNU_SOURCE, then include the other files. _GNU_SOURCE must be defined before including any system header file.

Other Resources§