Armide Documentation. Release Kyle Mayes

Size: px
Start display at page:

Download "Armide Documentation. Release Kyle Mayes"

Transcription

1 Armide Documentation Release Kyle Mayes December 19, 2014

2

3 Contents 1 Introduction Features License Table of Contents Getting Started Tutorial API Reference Indices and tables 17 i

4 ii

5 CHAPTER 1 Introduction Armide is a C99 library for parsing, manipulating, and writing TOML data. It also has the capability to write JSON data. 1.1 Features No dependencies on other libraries Full support for UTF-8 Well documented Well tested 1.2 License Armide is licensed under the MIT license. 1

6 2 Chapter 1. Introduction

7 CHAPTER 2 Table of Contents 2.1 Getting Started Downloading the Source The source for Armide is available from GitHub. $ git clone git@github.com:kylemayes/armide.git Compiling and Installing Armide currently can only be built with CMake. $ mkdir Build && cd Build $ cmake -DCMAKE_BUILD_TYPE=Release.. && make $ make install Testing To compile the tests, pass the -DARMIDE_BUILD_TESTS=ON argument to CMake. $ cmake -DCMAKE_BUILD_TYPE=Release -DARMIDE_BUILD_TESTS=ON.. && make $ make test # run the tests $ make valgrind-test # run the tests under valgrind Testing with toml-test toml-test is a language agnostic program that tests TOML parsers. If you have Go installed, you can run toml-test on Armide after having built the tests as described above. $ export GOPATH=$HOME/go $ go get github.com/burntsushi/toml-test # install toml-test $ $GOPATH/bin/toml-test./Tests/Interface # requires that you are in the build directory 3

8 2.1.3 Compiling Programs that Use Armide The inclusion of #include <Armide.h> includes everything you need to use Armide. Armide has no external dependencies, so you only need to link your program against libarmide. $ cc -o Test Test.c -larmide 2.2 Tutorial In this tutorial, we will be parsing and printing out the values of a TOML document and writing an altered version of the document. [project] name = "Armide" start = T10:48:57Z languages = [ "C", "C++" ] The full source is available as Example.c in the source code distribution under the Example directory. It can be compiled with cc -o Example Example.c -lm -larmide Parsing First, we include Armide.h and other necessary headers. #include <Armide.h> #include <stdio.h> Then, we read and parse Example.toml with toml_load_file(). int main(int argc, char* argv[]) { toml_error_t error; toml_t* toml = toml_load_file("example.toml", &error); if (toml == NULL) { printf("%s\n", error.message); } return -1; If the toml_load_file() function fails, it returns NULL and error is filled with the index, line number, column number, and type of the error as well as a descriptive error message. If parsing is successful, the returned toml_t will always be a table representing the root of the TOML document Manipulating We can then search for the table project with toml_table_get(). 4 Chapter 2. Table of Contents

9 toml_t* project = toml_table_get(toml, "project"); if (!toml_is_table(project)) { toml_decref(toml); } return -1; If there isn t a table member under the name project, toml_table_get() will return NULL. If its argument is NULL or not a table, toml_is_table() returns false. If toml_is_table() returns false, we need to free toml and return. However, toml_t* points to a reference counted type and thus should not be destroyed directly. Instead, we call toml_decref(), which will decrement the reference count (atomically) and destroy the value if the reference count reaches 0. Now that we have the project table, we can search for the members we are interested in. Here, we look for the name member and print it out if it exists and is a string. toml_t* name = toml_table_get(project, "name"); if (toml_is_string(name)) { printf("name = \"%s\"\n", toml_string_get(name)); } Here, we look for the start member and print it out if it exists and is a datetime. toml_t* start = toml_table_get(project, "start"); if (toml_is_datetime(start)) { char buffer[toml_datetime_size]; toml_datetime_print(start, buffer, sizeof(buffer)); } printf("datetime = %s\n", buffer); Datetimes in Armide are represented with the toml_utc_t datatype. The toml_datetime_print() function prints out a datetime to a buffer. Lastly, we find the languages member. If it is an array as we expect, we print out the size of the array and then use the toml_array_foreach() macro to iterate through each member and its index and print both. toml_t* languages = toml_table_get(project, "languages"); if (toml_is_array(languages)) { printf("languages.size = %zu\n", toml_array_get_size(languages)); size_t index = 0; toml_t* value = NULL; toml_array_foreach(languages, index, value) { if (toml_is_string(value)) { printf(" languages[%zu] = %s\n", index, toml_string_get(value)); 2.2. Tutorial 5

10 } } } Now, let s suppose that we want to add a value to this document and print it out. We could use the toml_table_set() function to add a new member. Warning: This code example is incorrect and is used for explanatory purposes. toml_table_set(project, "author", toml_create_string("kyle Mayes")); However, this would introduce a memory leak. toml_create_string(), like all toml_create_* functions, creates a new TOML value with a reference count of 1. toml_table_set() increments the reference count of its TOML value argument before placing it in the table or array. This means that the string created above will never be destroyed because it will have a reference count of 2 but toml_decref() will be called on it only once when its parent is destroyed. The solution to passing newly created values to functions like toml_table_set() is to use the variant ending with _with. These functions do not increment the reference count but instead steal the value. toml_table_set_with(project, "author", toml_create_string("kyle Mayes")); This ensures that the newly created string will always be destroyed when its parent is destroyed Writing Now that we have added a value to our TOML document, let s print it out. char* out = toml_dump(toml, 0); printf("%s\n", out); free(out); The toml_dump() function returns a string representation of any TOML value, but tables are the only TOML values that make valid TOML documents. There is also toml_dump_json() which, as its name suggests, fills a similar role but generates JSON instead of TOML. The second argument to these functions are the flags with which you can customize output. Information on these can be found in the API reference Cleaning Up Before we are done we need to ensure that toml is destroyed. toml_decref(toml); } return 0; The other TOML values we used do not need their reference counts decremented because they were only borrowed from their parent value and will be destroyed when their parent is destroyed. 6 Chapter 2. Table of Contents

11 If you want a toml_t* to outlive its parent, either use toml_incref() to increment its reference count or use toml_copy() or toml_deep_copy() to create a copy. Just remember to call toml_decref() when you are done! 2.3 API Reference Preface All external functions, types, and values are prefixed with toml_ or TOML_. Unless noted otherwise, a function returns either -1 or NULL on error depending on the return type of that function Value Representation toml_t This type is used to represent all TOML values. It always contains the type of the value and its reference count. The remaining contents are determined by the type of the value. This type should always be accessed through a pointer. It is a reference counted type and should not be destroyed directly. There are functions for querying its type, incrementing and decrementing its reference count, making copies, and accessing its type-specific contents. Type enum toml_type The type of a TOML value. TOML_ARRAY TOML_FLOAT TOML_TABLE TOML_STRING TOML_BOOLEAN TOML_INTEGER TOML_DATETIME TOML_NONE A value outside of the range of enum toml_type that represents an error or special value. enum toml_type toml_get_type(const toml_t* toml) Returns the type of the TOML value. toml must not be NULL. bool toml_is(const toml_t* toml, enum toml_type type) Returns true if toml is non-null and has the given type. bool toml_is_array(const toml_t* toml) bool toml_is_float(const toml_t* toml) bool toml_is_table(const toml_t* toml) bool toml_is_string(const toml_t* toml) bool toml_is_boolean(const toml_t* toml) bool toml_is_integer(const toml_t* toml) bool toml_is_datetime(const toml_t* toml) These functions return true is toml is non-null and has the specified type API Reference 7

12 Reference Counting toml_t* toml_incref(toml_t* toml) Atomically increments the reference count of toml and returns toml. void toml_decref(toml_t* toml) Atomically decrements the reference count of toml and destroys toml if the reference count has reached 0. When a TOML value is created, it has a reference count of one. Storing values in tables or arrays increments the reference count of that value unless you use one of the functions ending in _with. The TOML values you receive from functions such as toml_table_get() are borrowed from their parent table or array; you should not call toml_decref() on these values. To extend the lifetime of these borrowed values beyond the life of their parent table or array, either use toml_incref() to increase the value s reference count or create a copy with toml_copy() or toml_deep_copy() Array An array is a homogenous, ordered collection of TOML values. toml_t* toml_create_array(void) Returns an empty array or NULL on allocation failure. size_t toml_array_get_size(const toml_t* toml) Returns the size of the array or 0 if toml is not an array. size_t toml_array_get_type(const toml_t* toml) Returns the type of the array s elements or TOML_NONE if toml is not an array or is empty. toml_t* toml_array_get(const toml_t* toml, size_t index) Returns the value at index or NULL if toml is not a table or index is out of range. int toml_array_set(toml_t* toml, size_t index, toml_t* element) Increments the reference count of element before replacing the value at index with element. toml_decref() is called on the replaced value. Returns 0 on success or -1 if toml is not an array, index is out of range, or the type of element does not match the type of the other elements. int toml_array_set_with(toml_t* toml, size_t index, toml_t* element) The same as above but the reference count of element is not incremented. int toml_array_add(toml_t* toml, toml_t* element) Increments the reference count of element before appending element to the end of the array. Returns 0 on success or -1 if toml is not an array or if growing the array fails. int toml_array_add_with(toml_t* toml, toml_t* element) The same as above but the reference count of element is not incremented. int toml_array_insert(toml_t* toml, size_t index, toml_t* element) Increments the reference count of element before inserting element into the array at index. Returns 0 on success or -1 if toml is not an array, index is out of range, or if growing the array fails. int toml_array_insert_with(toml_t* toml, size_t index, toml_t* element) The same as above but the reference count of element is not incremented. int toml_array_remove(toml_t* toml, size_t index) Calls toml_decref() on the value at index before removing it from the array. Returns 0 on success or -1 if toml is not an array or index is out of range. 8 Chapter 2. Table of Contents

13 int toml_array_clear(toml_t* toml) Calls toml_decref() on all the array s values before clearing the array. Returns 0 on success or -1 if toml is not an array. toml_array_foreach(toml, INDEX, VALUE) A convenience macro for iterating over the indices and values of an array. size_t index = 0; toml_t* value = NULL; toml_array_foreach(array, index, value) { //... } Float A float is a double. toml_t* toml_create_float(double value) Returns a float with the supplied value or NULL on allocation failure. double toml_float_get(const toml_t* toml) Returns the double value of the float or 0.0 if toml is not a float. int toml_float_set(toml_t* toml, double value) Sets the double value of the float to the supplied value. Returns 0 on success or -1 if toml is not a float Table A table is an associative array mapping strings to TOML values of any type. toml_t* toml_create_table(void) Returns an empty table or NULL on allocation failure. size_t toml_table_get_size(const toml_t* toml) Returns the size of the table or 0 if toml is not a table. toml_t* toml_table_get(const toml_t* toml, const char* key) Returns the value associated with key or NULL if toml is not a table or if there is no value associated with key. toml_t* toml_table_get_n(const toml_t* toml, const char* key, size_t size) The same as above except only the first size characters of the key are considered. int toml_table_set(toml_t* toml, const char* key, toml_t* element) Increments the reference count of element before inserting element into the table under key. If there was a value previously associated with key, toml_decref() is called on it before it is replaced. Returns 0 on success or -1 if toml is not a table or if growing the table fails. int toml_table_set_n(toml_t* toml, const char* key, size_t size, toml_t* element) The same as above except only the first size characters of the key are considered. int toml_table_set_with(toml_t* toml, const char* key, toml_t* element) The same as toml_table_set() but the reference count of element is not incremented. int toml_table_set_with_n(toml_t* toml, const char* key, size_t size, toml_t* element) The same as above except only the first size characters of the key are considered API Reference 9

14 int toml_table_remove(toml_t* toml, const char* key) Calls toml_decref() on the value associated with key before removing it from the table. Returns 0 on success or -1 if toml is not a table, if there is no value associated with key, or if shrinking the table fails. int toml_table_remove_n(toml_t* toml, const char* key, size_t size) The same as above except only the first size characters of the key are considered. Iteration Unordered iteration over table key-value pairs is provided with an opaque iterator. void* toml_table_iter(const toml_t* toml) Returns an opaque iterator pointing to the first key-value pair in the table or NULL if toml is not a table or is empty. void* toml_table_iter_next(const toml_t* toml, void* iter) Returns an opaque iterator pointing to the next key-value pair after the one iter points to in the table or NULL if toml is not a table or iter is pointing at the last value. const char* toml_table_iter_get_key(void* iter) Returns the key of the key-value pair iter is pointing to. toml_t* toml_table_iter_get_value(void* iter) Returns the value of the key-value pair iter is pointing to. int toml_table_iter_set_value(void* iter, toml_t* toml) Increments the reference count of toml before replacing the value of the key-value pair iter points to with toml. toml_decref() is called on the previous value. The iterator is not invalidated. Returns 0 on success. int toml_table_iter_set_value_with(void* iter, toml_t* toml) The same as above but the reference count of toml is not incremented. toml_table_foreach(toml, ITER, KEY, VALUE) A convenience macro for iterating over the key-value pairs of a table. void* iter = NULL; const char* key = NULL; toml_t* value = NULL; toml_table_foreach(table, iter, key, value) { //... } Conversion Ordered iteration over table key-value pairs is supported with conversion to a list of key-value pairs. toml_key_value_t const char* key const toml_t* value toml_key_value_t* toml_table_to_list(const toml_t* toml) Returns an unordered list of the table s key-value pairs or NULL if toml is not a table or if allocation of the list fails. The list must be deallocated with free. 10 Chapter 2. Table of Contents

15 toml_comparer_t A typedef of the comparer function used to sort key-value pair lists. typedef int (*toml_comparer_t)(const toml_key_value_t*, const toml_key_value_t*); An example would be this function which sorts key-value pairs lexicographically by the key. int key_value_strcmp(const toml_key_value_t* a, const toml_key_value_t* b) { return strcmp(a->key, b->key); } toml_key_value_t* toml_table_to_ordered_list(const toml_t* toml, toml_comparer_t cmp) The same as toml_table_to_list() except the list is sorted using cmp String A string is a UTF-8 encoded string. Warning: Strings can contain embedded null terminators (\u0000). toml_t* toml_create_string(const char* value) Returns a string with a copy of the supplied value and the size set to strlen(value) or NULL on allocation failure. toml_t* toml_create_string_n(const char* value, size_t size) The same as above except only the first size characters of the value are copied and the size is set to size. toml_t* toml_create_string_with(char* value) Returns a string that has taken ownership of value or NULL on allocation failure. toml_t* toml_create_string_with_n(char* value, size_t size) The same as above except the size is set to size. size_t toml_string_get_size(const toml_t* toml) Returns the size of the string or 0 if toml is not a string. const char* toml_string_get(const toml_t* toml) Returns the string or NULL if toml is not a string. int toml_string_set(toml_t* toml, const char* value) Sets the value of the string to a copy of the supplied value and the size. Returns 0 on success or -1 if toml is not a string or on allocation failure. int toml_string_set_n(toml_t* toml, const char* value, size_t size) The same as above except only the first size characters of the value are copied and the size is set to size. int toml_string_set_with(toml_t* toml, char* value) Sets the value of the string to value and takes ownership of value. Returns 0 on success. int toml_string_set_with_n(toml_t* toml, char* value, size_t size) The same as above except the size is set to size Boolean A boolean is a bool API Reference 11

16 toml_t* toml_create_boolean(bool value) Returns a boolean with the supplied value or NULL on allocation failure. bool toml_boolean_get(const toml_t* toml) Returns the bool value of the boolean or false if toml is not a boolean. int toml_boolean_set(toml_t* toml, bool value) Sets the bool value of the boolean to the supplied value. Returns 0 on success or -1 if toml is not a boolean Integer An integer is an int64_t. toml_t* toml_create_integer(int64_t value) Returns a integer with the supplied value or NULL on allocation failure. int64_t toml_boolean_get(const toml_t* toml) Returns the int64_t value of the integer or 0 if toml is not a integer. int toml_boolean_set(toml_t* toml, int64_t value) Sets the int64_t value of the integer to the supplied value. Returns 0 on success or -1 if toml is not a integer Datetime A datetime is a toml_utc_t. toml_utc_t Represents a UTC time point down to nanosecond precision. int32_t year 1 to 9,999 inclusive. int32_t month 1 to 12 inclusive. int32_t day 1 to 28, 29, 30, or 31 inclusive depending on the month and year int32_t hour 0 to 23 inclusive int32_t minute 0 to 59 inclusive int32_t second 0 to 59 inclusive int32_t nanosecond 0 to 999,999,999 inclusive TOML_INVALID_TIME Equivalent to ((time_t)-1). Represents an invalid value. time_t toml_utc_to_time(toml_utc_t utc) Returns a time_t equivalent to the supplied toml_utc_t or TOML_INVALID_TIME if utc is invalid or before the Unix epoch ( T00:00:00Z). The nanosecond field of toml_utc_t is considered in that the second field is incremented if the nanosecond field is greater than or equal to 500,000, Chapter 2. Table of Contents

17 toml_utc_t toml_utc_from_time(time_t time) Returns a toml_utc_t equivalent to the supplied time_t. The nanosecond field of the toml_utc_t is set to 0. If time is invalid (because time_t is signed and time is negative), the returned toml_utc_t will have its year field set to -1. bool toml_utc_equal(toml_utc_t a, toml_utc_t b) Returns whether a and b are equal. toml_t* toml_create_datetime(toml_utc_t value) Returns a datetime with the supplied value or NULL if value is invalid or on allocation failure. toml_utc_t toml_datetime_get(const toml_t* toml) Returns the toml_utc_t value of the datetime or a toml_utc_t with its year field set to -1 if toml is not a datetime. TOML_DATETIME_SIZE The maximum buffer size needed to print a datetime (including a null terminator). int toml_datetime_print(const toml_t* toml, char* buffer, size_t size) Prints the datetime s value to a buffer in RFC 3339 format. Returns the amount of characters written if the buffer was large enough (this is guaranteed if it is at least as large as TOML_DATETIME_SIZE) or how many characters would have been written if the buffer is not large enough. int toml_datetime_set(toml_t* toml, toml_utc_t value) Sets the toml_utc_t value of the datetime to the supplied value. Returns 0 on success or -1 if toml is not a datetime or value is invalid Copying Due to the use of reference counting, you do not need to make copies of TOML values when placing them in arrays and tables. However, you may want to make a copy of a value when you want to modify it but need to keep the original value around too. toml_t* toml_copy(const toml_t* toml) Returns a shallow copy of the supplied TOML value or NULL on allocation failure. For arrays and tables, this means that only the top-level array or table is copied; the elements of the copied array or table are references to the elements in the original array or table. This means that modifying the copied array or table itself (adding, removing, clearing, etc.) will not modify the original but modifying the elements of the copied array or table will. toml_t* toml_deep_copy(const toml_t* toml) Returns a deep copy of the supplied TOML value or NULL on allocation failure. This only differs from toml_copy() for arrays and tables. For arrays and tables, the elements are copied with toml_deep_copy() recursively, resulting in a copy completely independent from the original Equality bool toml_equal(const toml_t* a, const toml_t* b) Returns whether the types of a and b are the same as well as the underlying values. Integers and floats are never equal even if their underlying values are equal. Arrays are considered equal if they are the same size and each element is equal to its corresponding element in the other array API Reference 13

18 Tables are considered equal if they are the same size and each key-value pair in one table is present in the other table and the values are equal. Strings are compared with strcmp, no Unicode string comparison functions are used Error Reporting enum toml_error_type The type of a TOML error. TOML_ERROR_NONE TOML_ERROR_FILE TOML_ERROR_INVALID TOML_ERROR_ENCODING TOML_ERROR_ALLOCATION toml_error_t No error reported. An error relating to opening or reading a file. An error relating to invalid TOML. An error relating to invalid UTF-8 encoding. An error relating to allocation failure. enum toml_error_type type The type of the error. size_t index The index in the source where the error occurred. TOML_ERROR_INVALID. Only applies to TOML_ERROR_ENCODING or int line The line in the source where the error occurred. Only applies to TOML_ERROR_INVALID. int column The column in the source where the error occurred. Only applies to TOML_ERROR_INVALID. char message[] The error message Parsing toml_t* toml_load(const char* source, toml_error_t* error) Parses the TOML document supplied as source. Populates error with appropriate information. Returns a table representing the root of the TOML document or NULL on error. toml_t* toml_load_n(const char* source, size_t size, toml_error_t* error) The same as above except only the first size characters of the source are used. toml_t* toml_load_with(char* source, toml_error_t* error) The same as toml_load() except the TOML parser takes ownership of the source. toml_t* toml_load_with_n(char* source, size_t size, toml_error_t* error) The same as above except only the first size characters of the source are used. Requires that the size of source be at least longer than size. toml_t* toml_load_file(const char* filepath, toml_error_t* error) Opens and reads the file at filepath and parses the contents as a TOML document. Populates error with appropriate information. Returns a table representing the root of the TOML document or NULL on error. 14 Chapter 2. Table of Contents

19 Writing The TOML and JSON writing functions take a flags parameter. TOML_COMPACT This flag determines whether the TOML or JSON will be reduced in size. TOML JSON No spaces in arrays No spaces between keys, =, and values No extra newlines between tables No spaces in arrays No spaces between : and values TOML_ASCII_ONLY This flag determines whether all non-ascii characters are escaped when possible. TOML JSON Keys are not strings in TOML so non-ascii characters will not be escaped in them Keys are strings in JSON so non-ascii characters will be escaped in them JSON does not support 4-byte escape sequences (\Uxxxxxxxx), so codepoints greater than 0xFFFF will be escaped as UTF-16 surrogate pairs TOML_PRECISION(VALUE) This flag determines the precision of floats when printed. The default value is 17. The value must be between 0 and 24 inclusive. TOML_INDENTATION(VALUE) This flag determines the number of spaces to be used as indentation. The default value is 2. The value must be between 0 and 16 inclusive. char* toml_dump(const toml_t* toml, uint64_t flags) Returns the TOML string representation of toml or NULL on allocation failure. The return value must be deallocated with free. char* toml_dump_json(const toml_t* toml, uint64_t flags) Returns the JSON string representation of toml or NULL on allocation failure. The return value must be deallocated with free. int toml_dump_file(const char* filepath, const toml_t* toml, uint64_t flags) Writes the TOML string representation of toml to the file at filepath, replacing it if it exists. Returns 0 on success or -1 on failure. int toml_dump_json_file(const char* filepath, const toml_t* toml, uint64_t flags) Writes the JSON string representation of toml to the file at filepath, replacing it if it exists. Returns 0 on success or -1 on failure API Reference 15

20 16 Chapter 2. Table of Contents

21 CHAPTER 3 Indices and tables genindex search 17

22 18 Chapter 3. Indices and tables

23 Index R RFC RFC 3339, 13 T toml_array_add (C function), 8 toml_array_add_with (C function), 8 toml_array_clear (C function), 8 toml_array_foreach (C macro), 9 toml_array_get (C function), 8 toml_array_get_size (C function), 8 toml_array_get_type (C function), 8 toml_array_insert (C function), 8 toml_array_insert_with (C function), 8 toml_array_remove (C function), 8 toml_array_set (C function), 8 toml_array_set_with (C function), 8 TOML_ASCII_ONLY (C macro), 15 toml_boolean_get (C function), 12 toml_boolean_set (C function), 12 TOML_COMPACT (C macro), 15 toml_comparer_t (C type), 10 toml_copy (C function), 13 toml_create_array (C function), 8 toml_create_boolean (C function), 11 toml_create_datetime (C function), 13 toml_create_float (C function), 9 toml_create_integer (C function), 12 toml_create_string (C function), 11 toml_create_string_n (C function), 11 toml_create_string_with (C function), 11 toml_create_string_with_n (C function), 11 toml_create_table (C function), 9 toml_datetime_get (C function), 13 toml_datetime_print (C function), 13 toml_datetime_set (C function), 13 TOML_DATETIME_SIZE (C macro), 13 toml_decref (C function), 8 toml_deep_copy (C function), 13 toml_dump (C function), 15 toml_dump_file (C function), 15 toml_dump_json (C function), 15 toml_dump_json_file (C function), 15 toml_equal (C function), 13 toml_error_t (C type), 14 toml_error_t.column (C member), 14 toml_error_t.index (C member), 14 toml_error_t.line (C member), 14 toml_error_t.type (C member), 14 toml_error_type (C type), 14 toml_float_get (C function), 9 toml_float_set (C function), 9 toml_get_type (C function), 7 toml_incref (C function), 8 TOML_INDENTATION (C macro), 15 TOML_INVALID_TIME (C macro), 12 toml_is (C function), 7 toml_is_array (C function), 7 toml_is_boolean (C function), 7 toml_is_datetime (C function), 7 toml_is_float (C function), 7 toml_is_integer (C function), 7 toml_is_string (C function), 7 toml_is_table (C function), 7 toml_key_value_t (C type), 10 toml_key_value_t.key (C member), 10 toml_key_value_t.value (C member), 10 toml_load (C function), 14 toml_load_file (C function), 14 toml_load_n (C function), 14 toml_load_with (C function), 14 toml_load_with_n (C function), 14 TOML_NONE (C macro), 7 TOML_PRECISION (C macro), 15 toml_string_get (C function), 11 toml_string_get_size (C function), 11 toml_string_set (C function), 11 toml_string_set_n (C function), 11 toml_string_set_with (C function), 11 toml_string_set_with_n (C function), 11 toml_t (C type), 7 19

24 toml_table_foreach (C macro), 10 toml_table_get (C function), 9 toml_table_get_n (C function), 9 toml_table_get_size (C function), 9 toml_table_iter (C function), 10 toml_table_iter_get_key (C function), 10 toml_table_iter_get_value (C function), 10 toml_table_iter_next (C function), 10 toml_table_iter_set_value (C function), 10 toml_table_iter_set_value_with (C function), 10 toml_table_remove (C function), 9 toml_table_remove_n (C function), 10 toml_table_set (C function), 9 toml_table_set_n (C function), 9 toml_table_set_with (C function), 9 toml_table_set_with_n (C function), 9 toml_table_to_list (C function), 10 toml_table_to_ordered_list (C function), 11 toml_type (C type), 7 toml_utc_equal (C function), 13 toml_utc_from_time (C function), 12 toml_utc_t (C type), 12 toml_utc_t.day (C member), 12 toml_utc_t.hour (C member), 12 toml_utc_t.minute (C member), 12 toml_utc_t.month (C member), 12 toml_utc_t.nanosecond (C member), 12 toml_utc_t.second (C member), 12 toml_utc_t.year (C member), 12 toml_utc_to_time (C function), Index

Jansson Documentation

Jansson Documentation Jansson Documentation Release 1.0.4 Petri Lehtinen August 20, 2013 CONTENTS i ii This is the documentation for Jansson 1.0.4, last updated August 20, 2013. Contents: CONTENTS 1 2 CONTENTS CHAPTER ONE

More information

libcbor Documentation

libcbor Documentation libcbor Documentation Release 0.4.0 Pavel Kalvoda Jan 02, 2017 Contents 1 Overview 3 2 Contents 5 2.1 Getting started.............................................. 5 2.2 Usage & preliminaries..........................................

More information

PRINCIPLES OF OPERATING SYSTEMS

PRINCIPLES OF OPERATING SYSTEMS PRINCIPLES OF OPERATING SYSTEMS Tutorial-1&2: C Review CPSC 457, Spring 2015 May 20-21, 2015 Department of Computer Science, University of Calgary Connecting to your VM Open a terminal (in your linux machine)

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above

More information

Common Misunderstandings from Exam 1 Material

Common Misunderstandings from Exam 1 Material Common Misunderstandings from Exam 1 Material Kyle Dewey Stack and Heap Allocation with Pointers char c = c ; char* p1 = malloc(sizeof(char)); char** p2 = &p1; Where is c allocated? Where is p1 itself

More information

ECE 264 Exam 2. 6:30-7:30PM, March 9, You must sign here. Otherwise you will receive a 1-point penalty.

ECE 264 Exam 2. 6:30-7:30PM, March 9, You must sign here. Otherwise you will receive a 1-point penalty. ECE 264 Exam 2 6:30-7:30PM, March 9, 2011 I certify that I will not receive nor provide aid to any other student for this exam. Signature: You must sign here. Otherwise you will receive a 1-point penalty.

More information

Approximately a Test II CPSC 206

Approximately a Test II CPSC 206 Approximately a Test II CPSC 206 Sometime in history based on Kelly and Pohl Last name, First Name Last 5 digits of ID Write your section number(s): All parts of this exam are required unless plainly and

More information

Midterm Exam Nov 8th, COMS W3157 Advanced Programming Columbia University Fall Instructor: Jae Woo Lee.

Midterm Exam Nov 8th, COMS W3157 Advanced Programming Columbia University Fall Instructor: Jae Woo Lee. Midterm Exam Nov 8th, 2012 COMS W3157 Advanced Programming Columbia University Fall 2012 Instructor: Jae Woo Lee About this exam: - There are 4 problems totaling 100 points: problem 1: 30 points problem

More information

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static

More information

String constants. /* Demo: string constant */ #include <stdio.h> int main() {

String constants. /* Demo: string constant */ #include <stdio.h> int main() { Strings 1 String constants 2 /* Demo: string constant */ #include s1.c int main() { printf("hi\n"); } String constants are in double quotes A backslash \ is used to include 'special' characters,

More information

CSCI 171 Chapter Outlines

CSCI 171 Chapter Outlines Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures

More information

CS2141 Software Development using C/C++ C++ Basics

CS2141 Software Development using C/C++ C++ Basics CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short

More information

Motivation was to facilitate development of systems software, especially OS development.

Motivation was to facilitate development of systems software, especially OS development. A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.

More information

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW IMPORTANT QUESTIONS IN C FOR THE INTERVIEW 1. What is a header file? Header file is a simple text file which contains prototypes of all in-built functions, predefined variables and symbolic constants.

More information

C Introduction. Comparison w/ Java, Memory Model, and Pointers

C Introduction. Comparison w/ Java, Memory Model, and Pointers CS 261 Fall 2018 Mike Lam, Professor C Introduction Comparison w/ Java, Memory Model, and Pointers Please go to socrative.com on your phone or laptop, choose student login and join room LAMJMU The C Language

More information

Motivation was to facilitate development of systems software, especially OS development.

Motivation was to facilitate development of systems software, especially OS development. A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.

More information

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu History and Evolution of Programming Languages 1. Explain the relationship between machine

More information

Chapter-8 DATA TYPES. Introduction. Variable:

Chapter-8 DATA TYPES. Introduction. Variable: Chapter-8 DATA TYPES Introduction To understand any programming languages we need to first understand the elementary concepts which form the building block of that program. The basic building blocks include

More information

This is CS50. Harvard University Fall Quiz 0 Answer Key

This is CS50. Harvard University Fall Quiz 0 Answer Key Quiz 0 Answer Key Answers other than the below may be possible. Binary Bulbs. 0. Bit- Sized Questions. 1. Because 0 is non- negative, we need to set aside one pattern of bits (000) for it, which leaves

More information

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ. C BOOTCAMP DAY 2 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Pointers 2 Pointers Pointers are an address in memory Includes variable addresses,

More information

ECE264 Spring 2013 Final Exam, April 30, 2013

ECE264 Spring 2013 Final Exam, April 30, 2013 ECE264 Spring 2013 Final Exam, April 30, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing

More information

Contents. Chapter 1 Overview of the JavaScript C Engine...1. Chapter 2 JavaScript API Reference...23

Contents. Chapter 1 Overview of the JavaScript C Engine...1. Chapter 2 JavaScript API Reference...23 Contents Chapter 1 Overview of the JavaScript C Engine...1 Supported Versions of JavaScript...1 How Do You Use the Engine?...2 How Does the Engine Relate to Applications?...2 Building the Engine...6 What

More information

MUST. MPI Runtime Error Detection Tool

MUST. MPI Runtime Error Detection Tool MUST MPI Runtime Error Detection Tool April 18, 2012 1 CONTENTS CONTENTS Contents 1 Introduction 3 2 Installation 3 2.1 P n MPI................................. 4 2.2 GTI..................................

More information

Call DLL from Limnor Applications

Call DLL from Limnor Applications Call DLL from Limnor Applications There is a lot of computer software in the format of dynamic link libraries (DLL). DLLCaller performer allows your applications to call DLL functions directly. Here we

More information

Programming Fundamentals - A Modular Structured Approach using C++ By: Kenneth Leroy Busbee

Programming Fundamentals - A Modular Structured Approach using C++ By: Kenneth Leroy Busbee 1 0 1 0 Foundation Topics 1 0 Chapter 1 - Introduction to Programming 1 1 Systems Development Life Cycle N/A N/A N/A N/A N/A N/A 1-8 12-13 1 2 Bloodshed Dev-C++ 5 Compiler/IDE N/A N/A N/A N/A N/A N/A N/A

More information

Linked data structures. EECS 211 Winter 2019

Linked data structures. EECS 211 Winter 2019 Linked data structures EECS 211 Winter 2019 2 Initial code setup $ cd eecs211 $ curl $URL211/lec/07linked.tgz tar zx $ cd 07linked Preliminaries 3 4 Two views on malloc and free The client/c view: malloc(n)

More information

Project 2: Shell with History1

Project 2: Shell with History1 Project 2: Shell with History1 See course webpage for due date. Submit deliverables to CourSys: https://courses.cs.sfu.ca/ Late penalty is 10% per calendar day (each 0 to 24 hour period past due). Maximum

More information

FLICONV-API. Generated by Doxygen

FLICONV-API. Generated by Doxygen FLICONV-API 1 1.8.13 Contents 1 FLUC ICONV Interface 1 1.1 CCSID's, encoding strings and defines................................ 1 1.2 Compatibility mode.......................................... 2 1.3

More information

CS201 Some Important Definitions

CS201 Some Important Definitions CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data

More information

ECE264 Fall 2013 Exam 3, November 20, 2013

ECE264 Fall 2013 Exam 3, November 20, 2013 ECE264 Fall 2013 Exam 3, November 20, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.

More information

ECE 244 Programming Fundamentals Fall Lab Assignment #5: Binary Search Trees

ECE 244 Programming Fundamentals Fall Lab Assignment #5: Binary Search Trees ECE 244 Programming Fundamentals Fall 2012 1. Objectives Lab Assignment #5: Binary Search Trees The objectives of this assignment are to provide you with more practice on the use of the various C++ concepts/constructs

More information

Memory Corruption 101 From Primitives to Exploit

Memory Corruption 101 From Primitives to Exploit Memory Corruption 101 From Primitives to Exploit Created by Nick Walker @ MWR Infosecurity / @tel0seh What is it? A result of Undefined Behaviour Undefined Behaviour A result of executing computer code

More information

CSE 565 Computer Security Fall 2018

CSE 565 Computer Security Fall 2018 CSE 565 Computer Security Fall 2018 Lecture 15: Software Security II Department of Computer Science and Engineering University at Buffalo 1 Software Vulnerabilities Buffer overflow vulnerabilities account

More information

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 14

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 14 BIL 104E Introduction to Scientific and Engineering Computing Lecture 14 Because each C program starts at its main() function, information is usually passed to the main() function via command-line arguments.

More information

by Pearson Education, Inc. All Rights Reserved.

by Pearson Education, Inc. All Rights Reserved. Let s improve the bubble sort program of Fig. 6.15 to use two functions bubblesort and swap. Function bubblesort sorts the array. It calls function swap (line 51) to exchange the array elements array[j]

More information

ECE 2400 Computer Systems Programming, Fall 2018 PA2: List and Vector Data Structures

ECE 2400 Computer Systems Programming, Fall 2018 PA2: List and Vector Data Structures School of Electrical and Computer Engineering Cornell University revision: 2018-09-25-13-37 1. Introduction The second programming assignment is designed to give you experience working with two important

More information

CS61, Fall 2012 Section 2 Notes

CS61, Fall 2012 Section 2 Notes CS61, Fall 2012 Section 2 Notes (Week of 9/24-9/28) 0. Get source code for section [optional] 1: Variable Duration 2: Memory Errors Common Errors with memory and pointers Valgrind + GDB Common Memory Errors

More information

Compiling and Running a C Program in Unix

Compiling and Running a C Program in Unix CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 95 ] Compiling and Running a C Program in Unix Simple scenario in which your program is in a single file: Suppose you want to name

More information

MUST. MPI Runtime Error Detection Tool

MUST. MPI Runtime Error Detection Tool MUST MPI Runtime Error Detection Tool November 9, 2011 1 CONTENTS CONTENTS Contents 1 Introduction 3 2 Installation 3 2.1 P n MPI................................. 4 2.2 GTI..................................

More information

Introduction to C. Robert Escriva. Cornell CS 4411, August 30, Geared toward programmers

Introduction to C. Robert Escriva. Cornell CS 4411, August 30, Geared toward programmers Introduction to C Geared toward programmers Robert Escriva Slide heritage: Alin Dobra Niranjan Nagarajan Owen Arden Cornell CS 4411, August 30, 2010 1 Why C? 2 A Quick Example 3 Programmer s Responsibilities

More information

Final Exam. 11 May 2018, 120 minutes, 26 questions, 100 points

Final Exam. 11 May 2018, 120 minutes, 26 questions, 100 points Name: CS520 Final Exam 11 May 2018, 120 minutes, 26 questions, 100 points The exam is closed book and notes. Please keep all electronic devices turned off and out of reach. Note that a question may require

More information

This document contains the questions and solutions to the CS107 midterm given in Winter 2018 by instructor Chris Gregg. This was a 120-minute exam.

This document contains the questions and solutions to the CS107 midterm given in Winter 2018 by instructor Chris Gregg. This was a 120-minute exam. This document contains the questions and solutions to the CS107 midterm given in Winter 2018 by instructor Chris Gregg. This was a 120-minute exam. Midterm questions Problem 1: Bits, bytes, and numbers

More information

Data Structures in C. C Programming and Software Tools. N.C. State Department of Computer Science

Data Structures in C. C Programming and Software Tools. N.C. State Department of Computer Science Data Structures in C C Programming and Software Tools N.C. State Department of Computer Science Data Structures in C The combination of pointers, structs, and dynamic memory allocation allows for creation

More information

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been

More information

Model Viva Questions for Programming in C lab

Model Viva Questions for Programming in C lab Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous

More information

MDF4 Lib. Product Information

MDF4 Lib. Product Information Product Information Table of Contents 1 Overview...3 1.1 Introduction...3 1.2 Application Areas...3 1.3 Overview of Advantages...3 2 Features and Advantages...4 2.1 Supported MDF Versions...4 3 Functional

More information

Contents. A Review of C language. Visual C Visual C++ 6.0

Contents. A Review of C language. Visual C Visual C++ 6.0 A Review of C language C++ Object Oriented Programming Pei-yih Ting NTOU CS Modified from www.cse.cuhk.edu.hk/~csc2520/tuto/csc2520_tuto01.ppt 1 2 3 4 5 6 7 8 9 10 Double click 11 12 Compile a single source

More information

ECE551 Midterm Version 1

ECE551 Midterm Version 1 Name: ECE551 Midterm Version 1 NetID: There are 7 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly. This exam must be individual

More information

COMP 2355 Introduction to Systems Programming

COMP 2355 Introduction to Systems Programming COMP 2355 Introduction to Systems Programming Christian Grothoff christian@grothoff.org http://grothoff.org/christian/ 1 Functions Similar to (static) methods in Java without the class: int f(int a, int

More information

Data Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Data Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani Data Types, Variables and Arrays OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani Identifiers in Java Identifiers are the names of variables, methods, classes, packages and interfaces. Identifiers must

More information

C: Pointers, Arrays, and strings. Department of Computer Science College of Engineering Boise State University. August 25, /36

C: Pointers, Arrays, and strings. Department of Computer Science College of Engineering Boise State University. August 25, /36 Department of Computer Science College of Engineering Boise State University August 25, 2017 1/36 Pointers and Arrays A pointer is a variable that stores the address of another variable. Pointers are similar

More information

FDK API Manual. June ITS Company

FDK API Manual. June ITS Company FDK API Manual for C June 2015 ITS Company Contents Overview 1 System Environments 1 Installation files. 1 Runtime Environments. 1 Sample codes for using CallFDK API 1 CallFdk functions.. 5 int CallFdk_Initialize().

More information

C++ Programming Chapter 7 Pointers

C++ Programming Chapter 7 Pointers C++ Programming Chapter 7 Pointers Yih-Peng Chiou Room 617, BL Building (02) 3366-3603 ypchiou@cc.ee.ntu.edu.tw Photonic Modeling and Design Lab. Graduate Institute of Photonics and Optoelectronics & Department

More information

CSE 333 Midterm Exam Sample Solution 5/10/13

CSE 333 Midterm Exam Sample Solution 5/10/13 Question 1. (18 points) Consider these two C files: a.c void f(int p); int main() { f(17); return 0; b.c void f(char *p) { *p = 'x'; (a) Why is the program made from a.c and b.c incorrect? What would you

More information

JTSK Programming in C II C-Lab II. Lecture 3 & 4

JTSK Programming in C II C-Lab II. Lecture 3 & 4 JTSK-320112 Programming in C II C-Lab II Lecture 3 & 4 Xu (Owen) He Spring 2018 Slides modified from Dr. Kinga Lipskoch Planned Syllabus The C Preprocessor Bit Operations Pointers and Arrays (Dynamically

More information

dmrlib Documentation Release Wijnand Modderman-Lenstra

dmrlib Documentation Release Wijnand Modderman-Lenstra dmrlib Documentation Release 0.99.3 Wijnand Modderman-Lenstra September 03, 2016 Contents 1 Overview 1 2 Documentation 3 2.1 bits: bit and byte manipulation...................................... 3 2.2

More information

c-lambda: C FFI via raco ctool

c-lambda: C FFI via raco ctool c-lambda: C FFI via raco ctool Version 5.1.3 August 15, 2011 (require compiler/cffi) The compiler/cffi module relies on a C compiler to statically construct an interface to C code through directives embedded

More information

Types, Variables, and Constants

Types, Variables, and Constants , Variables, and Constants What is a Type The space in which a value is defined Space All possible allowed values All defined operations Integer Space whole numbers +, -, x No divide 2 tj Why Types No

More information

Exercise Session 2 Systems Programming and Computer Architecture

Exercise Session 2 Systems Programming and Computer Architecture Systems Group Department of Computer Science ETH Zürich Exercise Session 2 Systems Programming and Computer Architecture Herbstsemester 216 Agenda Linux vs. Windows Working with SVN Exercise 1: bitcount()

More information

Understanding Pointers

Understanding Pointers Division of Mathematics and Computer Science Maryville College Pointers and Addresses Memory is organized into a big array. Every data item occupies one or more cells. A pointer stores an address. A pointer

More information

CS 220: Introduction to Parallel Computing. Input/Output. Lecture 7

CS 220: Introduction to Parallel Computing. Input/Output. Lecture 7 CS 220: Introduction to Parallel Computing Input/Output Lecture 7 Input/Output Most useful programs will provide some type of input or output Thus far, we ve prompted the user to enter their input directly

More information

C mini reference. 5 Binary numbers 12

C mini reference. 5 Binary numbers 12 C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char

More information

BİL200 TUTORIAL-EXERCISES Objective:

BİL200 TUTORIAL-EXERCISES Objective: Objective: The purpose of this tutorial is learning the usage of -preprocessors -header files -printf(), scanf(), gets() functions -logic operators and conditional cases A preprocessor is a program that

More information

A Quick Introduction to C Programming

A Quick Introduction to C Programming A Quick Introduction to C Programming 1 C Syntax and Hello World What do the < > mean? #include inserts another file..h files are called header files. They contain stuff needed to interface to libraries

More information

Advanced Pointer & Data Storage

Advanced Pointer & Data Storage 18, 19: storage classes 14: Preprocessor & Polymorphism in C) 15 : command line building 26 : stdarg Advanced Pointer & Data Storage (for ch. 14, 15 18, 19, 26) Contents Preprocessor & Polymorphism in

More information

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level

More information

Section 3: File I/O, JSON, Generics. Meghan Cowan

Section 3: File I/O, JSON, Generics. Meghan Cowan Section 3: File I/O, JSON, Generics Meghan Cowan POSIX Family of standards specified by the IEEE Maintains compatibility across variants of Unix-like OS Defines API and standards for basic I/O: file, terminal

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

CPSC 3740 Programming Languages University of Lethbridge. Data Types

CPSC 3740 Programming Languages University of Lethbridge. Data Types Data Types A data type defines a collection of data values and a set of predefined operations on those values Some languages allow user to define additional types Useful for error detection through type

More information

CS349/SE382 A1 C Programming Tutorial

CS349/SE382 A1 C Programming Tutorial CS349/SE382 A1 C Programming Tutorial Erin Lester January 2005 Outline Comments Variable Declarations Objects Dynamic Memory Boolean Type structs, enums and unions Other Differences The Event Loop Comments

More information

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

CSci 4061 Introduction to Operating Systems. Programs in C/Unix CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,

More information

C Review. MaxMSP Developers Workshop Summer 2009 CNMAT

C Review. MaxMSP Developers Workshop Summer 2009 CNMAT C Review MaxMSP Developers Workshop Summer 2009 CNMAT C Syntax Program control (loops, branches): Function calls Math: +, -, *, /, ++, -- Variables, types, structures, assignment Pointers and memory (***

More information

Call The Project Dynamic-Memory

Call The Project Dynamic-Memory 1 2 2 Call The Project Dynamic-Memory 4 4 Copy-Paste Main # include "Utilities.hpp" int main(int argc, char * argv[]) { short int *PtrNo; (*PtrNo) = 5; printf ("(*PtrNo) = %d\n", (*PtrNo)); } getchar();

More information

LESSON 4. The DATA TYPE char

LESSON 4. The DATA TYPE char LESSON 4 This lesson introduces some of the basic ideas involved in character processing. The lesson discusses how characters are stored and manipulated by the C language, how characters can be treated

More information

ICU 58 SpoofChecker API Changes

ICU 58 SpoofChecker API Changes ICU 58 SpoofChecker API Changes This is a proposal for changes to the SpoofChecker API in Java and C++. The changes are intended to reflect the most recent version of UTS 39. SpoofChecker API Changes,

More information

CSE 220: Systems Programming

CSE 220: Systems Programming CSE 220: Systems Programming Pointers and Data Representation Ethan Blanton Department of Computer Science and Engineering University at Buffalo More on void Pointers Void pointers are powerful for raw

More information

C: Arrays, and strings. Department of Computer Science College of Engineering Boise State University. September 11, /16

C: Arrays, and strings. Department of Computer Science College of Engineering Boise State University. September 11, /16 Department of Computer Science College of Engineering Boise State University September 11, 2017 1/16 1-dimensional Arrays Arrays can be statically declared in C, such as: int A [100]; The space for this

More information

PES INSTITUTE OF TECHNOLOGY (BSC) I MCA, First IA Test, November 2015 Programming Using C (13MCA11) Solution Set Faculty: Jeny Jijo

PES INSTITUTE OF TECHNOLOGY (BSC) I MCA, First IA Test, November 2015 Programming Using C (13MCA11) Solution Set Faculty: Jeny Jijo PES INSTITUTE OF TECHNOLOGY (BSC) I MCA, First IA Test, November 2015 Programming Using C (13MCA11) Solution Set Faculty: Jeny Jijo 1. (a)what is an algorithm? Draw a flowchart to print N terms of Fibonacci

More information

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14 C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

More information

CSE 333 Midterm Exam 5/10/13

CSE 333 Midterm Exam 5/10/13 Name There are 5 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes, closed

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables

More information

ECE 551D Spring 2018 Midterm Exam

ECE 551D Spring 2018 Midterm Exam Name: ECE 551D Spring 2018 Midterm Exam NetID: There are 6 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly. This exam must be individual

More information

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites: C Programming Code: MBD101 Duration: 10 Hours Prerequisites: You are a computer science Professional/ graduate student You can execute Linux/UNIX commands You know how to use a text-editing tool You should

More information

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics

More information

Dynamic memory allocation

Dynamic memory allocation Dynamic memory allocation outline Memory allocation functions Array allocation Matrix allocation Examples Memory allocation functions (#include ) malloc() Allocates a specified number of bytes

More information

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler

More information

Chapter 5. Section 5.4 The Common String Library Functions. CS 50 Hathairat Rattanasook

Chapter 5. Section 5.4 The Common String Library Functions. CS 50 Hathairat Rattanasook Chapter 5 Section 5.4 The Common String Library Functions CS 50 Hathairat Rattanasook Library Functions We already discussed the library function fgets() Library functions are available: to find the length

More information

by Pearson Education, Inc. All Rights Reserved. 2

by Pearson Education, Inc. All Rights Reserved. 2 Data that is formatted and written to a sequential file as shown in Section 17.4 cannot be modified without the risk of destroying other data in the file. For example, if the name White needs to be changed

More information

Memory Management. a C view. Dr Alun Moon KF5010. Computer Science. Dr Alun Moon (Computer Science) Memory Management KF / 24

Memory Management. a C view. Dr Alun Moon KF5010. Computer Science. Dr Alun Moon (Computer Science) Memory Management KF / 24 Memory Management a C view Dr Alun Moon Computer Science KF5010 Dr Alun Moon (Computer Science) Memory Management KF5010 1 / 24 The Von Neumann model Memory Architecture One continuous address space Program

More information

A skeleton file has been provided for you to use in both checkpoints.

A skeleton file has been provided for you to use in both checkpoints. University of Illinois, Urbana-Champaign ECE190 MP5 Website Crawler Program Description: In this MP, you need to write a C program to process a list of websites given to you in a series of text files.

More information

Programming the DMCC in C

Programming the DMCC in C Programming the DMCC in C Task This tutorial will teach you how to write your first program on a dual motor control cape (DMCC) through the BeagleBone microcontroller. The DMCC is a stackable board that

More information

ECE551 Midterm Version 2

ECE551 Midterm Version 2 Name: ECE551 Midterm Version 2 NetID: There are 7 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly. This exam must be individual

More information

TI2725-C, C programming lab, course

TI2725-C, C programming lab, course Valgrind tutorial Valgrind is a tool which can find memory leaks in your programs, such as buffer overflows and bad memory management. This document will show per example how Valgrind responds to buggy

More information

An overview of Java, Data types and variables

An overview of Java, Data types and variables An overview of Java, Data types and variables Lecture 2 from (UNIT IV) Prepared by Mrs. K.M. Sanghavi 1 2 Hello World // HelloWorld.java: Hello World program import java.lang.*; class HelloWorld { public

More information

CS Programming In C

CS Programming In C CS 24000 - Programming In C Week Two: Basic C Program Organization and Data Types Zhiyuan Li Department of Computer Science Purdue University, USA 2 int main() { } return 0; The Simplest C Program C programs

More information

Dynamic Memory Allocation and Command-line Arguments

Dynamic Memory Allocation and Command-line Arguments Dynamic Memory Allocation and Command-line Arguments CSC209: Software Tools and Systems Programming Furkan Alaca & Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Week 3

More information

malloc(), calloc(), realloc(), and free()

malloc(), calloc(), realloc(), and free() 1 next CITS2002 CITS2002 schedule Dynamic data structures Initially, we focused on scalar and array variables, whose size is known at compile-time. More recently, we've focused on arrays of values, whose

More information

Computers Programming Course 5. Iulian Năstac

Computers Programming Course 5. Iulian Năstac Computers Programming Course 5 Iulian Năstac Recap from previous course Classification of the programming languages High level (Ada, Pascal, Fortran, etc.) programming languages with strong abstraction

More information