C mini reference. 5 Binary numbers 12

Size: px
Start display at page:

Download "C mini reference. 5 Binary numbers 12"

Transcription

1 C mini reference Contents 1 Input/Output: stdio.h int printf ( const char * format,... ); int scanf ( const char * format,... ); char * fgets ( char * str, int num, FILE * stream ); FILE * fopen ( const char * filename, const char * mode ); int fclose ( FILE * stream ); int fseek ( FILE * stream, long int offset, int origin ); Other I/O functions size t fread ( void * ptr, size t size, size t count, FILE * stream ); int fgetc ( FILE * stream ); size t fwrite ( const void * ptr, size t size, size t count, FILE * stream ); int fputc ( int character, FILE * stream ); long int ftell ( FILE * stream ); String handling: string.h char * strcpy ( char * destination, const char * source ); char * strcat ( char * destination, const char * source ); size t strlen ( const char * str ); int strcmp ( const char * str1, const char * str2 ); Other string functions char * strncpy ( char * destination, const char * source, size t num ); char * strncat ( char * destination, const char * source, size t num ); void * memset ( void * ptr, int value, size t num ); char * strtok ( char * str, const char * delimiters ); char * strstr ( const char *, const char * ); Memory handling: stdlib.h void* malloc (size t size); void* calloc (size t num, size t size); void* realloc (void* ptr, size t size); void free (void* ptr); void qsort (void* base, size t num, size t size, int (*compar)(const void*,const void*)); Character handling: ctype.h 11.1 int isalnum ( int c ); int isalpha ( int c ); int isdigit ( int c ); int isprint ( int c ); int isspace ( int c ); int tolower ( int c ); int toupper ( int c ); Binary numbers 12 6 Command line First things to do Compiling your program Running your program Using valgrind to check for memory errors

2 1 Input/Output: stdio.h 1.1 int printf ( const char * format,... ); format A format specifier follows this prototype: %[flags][width][.precision][length]specifier specifier Output Example d or i Signed decimal integer 392 u Unsigned decimal integer 7235 x Unsigned hexadecimal integer 7fa f Decimal floating point, lowercase c Character a s String of characters sample On success, the total number of characters written is returned. 1.2 int scanf ( const char * format,... ); format A format specifier follows this prototype: %[*][width][length]specifier specifier Description Characters extracted i Integer Any number of digits, optionally preceded by a sign (+ or -). Decimal digits assumed by default (0-9), but a 0 prefix introduces octal digits (0-7), and 0x hexadecimal digits (0-f). Signed argument. d or u Decimal integer Any number of decimal digits (0-9), optionally preceded by a sign (+ or -). d is for a signed argument, and u for an unsigned. f Floating point number A series of decimal digits, optionally containing a decimal point, optionally preceeded by a sign (+ or -) and optionally followed by the e or E character and a decimal integer c Character The next character. If a width other than 1 is specified, the function reads exactly width characters and stores them in the successive locations of the array passed as argument. No null character is appended at the end. s String of characters Any number of non-whitespace characters, stopping at the first whitespace character found. A terminating null character is automatically added at the end of the stored sequence.... (additional arguments) Depending on the format string, the function may expect a sequence of additional arguments, each containing a pointer to allocated storage where the interpretation of the extracted characters is stored with the appropriate type. On success, the function returns the number of items of the argument list successfully filled. This count can match the expected number of items or be less (even zero) due to a matching failure, a reading error, or the reach of the end-of-file. 2

3 1.3 char * fgets ( char * str, int num, FILE * stream ); Reads characters from stream and stores them as a C string into str until (num-1) characters have been read or either a newline or the end-of-file is reached, whichever happens first. A newline character makes fgets stop reading, but it is considered a valid character by the function and included in the string copied to str. A terminating null character is automatically appended after the characters copied to str. str Pointer to an array of chars where the string read is copied. num Maximum number of characters to be copied into str (including the terminating null-character). stream Pointer to a FILE object that identifies an input stream. stdin can be used as argument to read from the standard input. On success, the function returns str. If the end-of-file is encountered while attempting to read a character, the eof indicator is set (feof). If this happens before any characters could be read, the pointer returned is a null pointer (and the contents of str remain unchanged). 1 / f g e t s example / 2 #i n c l u d e <s t d i o. h> 3 i n t main ( ) 5 { 6 FILE p F i l e ; 7 char mystring [ ] ; 8 9 p F i l e = fopen ( m y f i l e. t x t, r ) ; 10 i f ( p F i l e == NULL) p e r r o r ( Error opening f i l e ) ; 11 e l s e { 12 i f ( f g e t s ( mystring, 100, p F i l e )!= NULL ) 13 puts ( mystring ) ; 1 f c l o s e ( p F i l e ) ; 15 } 16 r e t u r n 0 ; 17 } 1. FILE * fopen ( const char * filename, const char * mode ); Opens the file whose name is specified in the parameter filename and associates it with a stream that can be identified in future operations by the FILE pointer returned. filename C string containing the name of the file to be opened. mode r w read: Open file for input operations. The file must exist. write: Create an empty file for output operations. If a file with the same name already exists, its contents are discarded and the file is treated as a new empty file. 3

4 If the file is successfully opened, the function returns a pointer to a FILE object that can be used to identify the stream on future operations. Otherwise, a null pointer is returned. 1 / fopen example / 2 #i n c l u d e <s t d i o. h> 3 i n t main ( ) { 5 FILE p F i l e ; 6 p F i l e = fopen ( m y f i l e. t x t, w ) ; 7 i f ( p F i l e!=null) 8 { 9 f p u t s ( fopen example, p F i l e ) ; 10 f c l o s e ( p F i l e ) ; 11 } 12 r e t u r n 0 ; 13 } 1.5 int fclose ( FILE * stream ); Closes the file associated with the stream and disassociates it. stream Pointer to a FILE object that specifies the stream to be closed. 1.6 int fseek ( FILE * stream, long int offset, int origin ); Sets the position indicator associated with the stream to a new position. stream Pointer to a FILE object that identifies the stream. offset Text files: Either zero, or a value returned by ftell. origin Position used as reference for the offset. It is specified by one of the following constants defined in cstdio exclusively to be used as arguments for this function: SEEK SET Beginning of file SEEK CUR Current position of the file pointer SEEK END End of file * If successful, the function returns zero. Otherwise, it returns non-zero value. 1.7 Other I/O functions size t fread ( void * ptr, size t size, size t count, FILE * stream ); Reads an array of count elements, each one with a size of size bytes, from the stream and stores them in the block of memory specified by ptr.

5 1.7.2 int fgetc ( FILE * stream ); Returns the character currently pointed by the internal file position indicator of the specified stream. The internal file position indicator is then advanced to the next character size t fwrite ( const void * ptr, size t size, size t count, FILE * stream ); Writes an array of count elements, each one with a size of size bytes, from the block of memory pointed by ptr to the current position in the stream int fputc ( int character, FILE * stream ); Writes a character to the stream and advances the position indicator long int ftell ( FILE * stream ); Returns the current value of the position indicator of the stream. 2 String handling: string.h 2.1 char * strcpy ( char * destination, const char * source ); Copies the C string pointed by source into the array pointed by destination, including the terminating null character (and stopping at that point). destination Pointer to the destination array where the content is to be copied. source C string to be copied. destination is returned. 1 / s t r c p y example / 2 #i n c l u d e <s t d i o. h> 3 #i n c l u d e <s t r i n g. h> 5 i n t main ( ) 6 { 7 char s t r 1 []= Sample s t r i n g ; 8 char s t r 2 [ 0 ] ; 9 s t r c p y ( s t r 2, s t r 1 ) ; 10 r e t u r n 0 ; 11 } 2.2 char * strcat ( char * destination, const char * source ); Appends a copy of the source string to the destination string. The terminating null character in destination is overwritten by the first character of source, and a null-character is included at the end of the new string formed by the concatenation of both in destination. 5

6 destination Pointer to the destination array, which should contain a C string, and be large enough to contain the concatenated resulting string. source C string to be appended. This should not overlap destination. destination is returned. 1 / s t r c a t example / 2 #i n c l u d e <s t d i o. h> 3 #i n c l u d e <s t r i n g. h> 5 i n t main ( ) 6 { 7 char s t r [ 8 0 ] ; 8 s t r c p y ( s t r, t h e s e ) ; 9 s t r c a t ( s t r, s t r i n g s ) ; 10 s t r c a t ( s t r, are ) ; 11 s t r c a t ( s t r, concatenated. ) ; 12 puts ( s t r ) ; 13 r e t u r n 0 ; 1 } 2.3 size t strlen ( const char * str ); Returns the length of the C string str. The length of a C string is determined by the terminating null-character: A C string is as long as the number of characters between the beginning of the string and the terminating null character (without including the terminating null character itself). str C string. The length of string. 2. int strcmp ( const char * str1, const char * str2 ); Compares the C string str1 to the C string str2. str1 C string to be compared. str2 C string to be compared. 6

7 Returns an integral value indicating the relationship between the strings: >0 the first character that does not match has a lower value in ptr1 than in ptr2 0 the contents of both strings are equal <0 the first character that does not match has a greater value in ptr1 than in ptr2 1 / strcmp example / 2 #i n c l u d e <s t d i o. h> 3 #i n c l u d e <s t r i n g. h> 5 i n t main ( ) 6 { 7 char key [ ] = apple ; 8 char b u f f e r [ 8 0 ] ; 9 do { 10 p r i n t f ( Guess my f a v o r i t e f r u i t? ) ; 11 f f l u s h ( stdout ) ; 12 s c a n f ( %79s, b u f f e r ) ; 13 } w h i l e ( strcmp ( key, b u f f e r )!= 0) ; 1 puts ( Correct answer! ) ; 15 r e t u r n 0 ; 16 } 2.5 Other string functions char * strncpy ( char * destination, const char * source, size t num ); Copies the first num characters of source to destination. If the end of the source C string (which is signaled by a null-character) is found before num characters have been copied, destination is padded with zeros until a total of num characters have been written to it char * strncat ( char * destination, const char * source, size t num ); Appends the first num characters of source to destination, plus a terminating null-character. If the length of the C string in source is less than num, only the content up to the terminating null-character is copied void * memset ( void * ptr, int value, size t num ); Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char) char * strtok ( char * str, const char * delimiters ); A sequence of calls to this function split str into tokens, which are sequences of contiguous characters separated by any of the characters that are part of delimiters. On a first call, the function expects a C string as argument for str, whose first character is used as the starting location to scan for tokens. In subsequent calls, the function expects a null pointer and uses the position right after the end of the last token as the new starting location for scanning char * strstr ( const char *, const char * ); Returns a pointer to the first occurrence of str2 in str1, or a null pointer if str2 is not part of str1. 7

8 3 Memory handling: stdlib.h 3.1 void* malloc (size t size); Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. size Size of the memory block, in bytes. On success, a pointer to the memory block allocated by the function. 1 / malloc example : random s t r i n g g e n e r a t o r / 2 #i n c l u d e <s t d i o. h> / p r i n t f, scanf, NULL / 3 #i n c l u d e <s t d l i b. h> / malloc, f r e e, rand / 5 i n t main ( ) 6 { 7 i n t i, n ; 8 char b u f f e r ; 9 10 p r i n t f ( How long do you want the s t r i n g? ) ; 11 s c a n f ( %d, &i ) ; b u f f e r = malloc ( i +1) ; 1 i f ( b u f f e r==null) e x i t ( 1 ) ; f o r ( n=0; n<i ; n++) 17 b u f f e r [ n]= rand ( )%26+ a ; 18 b u f f e r [ i ]= \0 ; p r i n t f ( Random s t r i n g : %s \n, b u f f e r ) ; 21 f r e e ( b u f f e r ) ; r e t u r n 0 ; 2 } 3.2 void* calloc (size t num, size t size); Allocates a block of memory for an array of num elements, each of them size bytes long, and initializes all its bits to zero. The effective result is the allocation of a zero-initialized memory block of (num*size) bytes. num Number of elements to allocate. size Size of each element. On success, a pointer to the memory block allocated by the function. 8

9 3.3 void* realloc (void* ptr, size t size); Changes the size of the memory block pointed to by ptr. The function may move the memory block to a new location (whose address is returned by the function). The content of the memory block is preserved up to the lesser of the new and old sizes, even if the block is moved to a new location. If the new size is larger, the value of the newly allocated portion is indeterminate. In case that ptr is a null pointer, the function behaves like malloc, assigning a new block of size bytes and returning a pointer to its beginning. ptr Pointer to a memory block previously allocated with malloc, calloc or realloc. Alternatively, this can be a null pointer, in which case a new block is allocated (as if malloc was called). size New size for the memory block, in bytes. A pointer to the reallocated memory block, which may be either the same as ptr or a new location. 1 / r e a l l o c example : rememb o matic / 2 #i n c l u d e <s t d i o. h> / p r i n t f, scanf, puts / 3 #i n c l u d e <s t d l i b. h> / r e a l l o c, f r e e, e x i t, NULL / 5 i n t main ( ) 6 { 7 i n t input, n ; 8 i n t count = 0 ; 9 i n t numbers = NULL; 10 i n t more numbers = NULL; do { 13 p r i n t f ( Enter an i n t e g e r value (0 to end ) : ) ; 1 s c a n f ( %d, &input ) ; 15 count++; more numbers = r e a l l o c ( numbers, count s i z e o f ( i n t ) ) ; i f ( more numbers!=null) { 20 numbers=more numbers ; 21 numbers [ count 1]= input ; 22 } 23 e l s e { 2 f r e e ( numbers ) ; 25 puts ( Error ( r e ) a l l o c a t i n g memory ) ; 26 e x i t ( 1 ) ; 27 } 28 } w h i l e ( input!=0) ; p r i n t f ( Numbers e n t e r e d : ) ; 31 f o r ( n=0;n<count ; n++) p r i n t f ( %d, numbers [ n ] ) ; 32 f r e e ( numbers ) ; 33 3 r e t u r n 0 ; 35 } 3. void free (void* ptr); A block of memory previously allocated by a call to malloc, calloc or realloc is deallocated, making it available again for further allocations. 9

10 3.5 void qsort (void* base, size t num, size t size, int (*compar)(const void*,const void*)); Sorts the num elements of the array pointed to by base, each element size bytes long, using the compar function to determine the order. The sorting algorithm used by this function compares pairs of elements by calling the specified compar function with pointers to them as argument. The function does not return any value, but modifies the content of the array pointed to by base reordering its elements as defined by compar. base Pointer to the first object of the array to be sorted, converted to a void*. num Number of elements in the array pointed to by base. size Size in bytes of each element in the array. compar Pointer to a function that compares two elements. This function is called repeatedly by qsort to compare two elements. It shall follow the following prototype: int compar (const void* p1, const void* p2); Taking two pointers as arguments (both converted to const void*). The function defines the order of the elements by returning (in a stable and transitive manner): >0 The element pointed to by p1 goes after the element pointed to by p2 0 The element pointed to by p1 is equivalent to the element pointed to by p2 <0 The element pointed to by p1 goes before the element pointed to by p2 For types that can be compared using regular relational operators, a general compar function may look like: 1 i n t comparemytype ( c o n s t void a, c o n s t void b ) 2 { 3 i f ( (MyType ) a < (MyType ) b ) r e t u r n 1; i f ( (MyType ) a == (MyType ) b ) r e t u r n 0 ; 5 i f ( (MyType ) a > (MyType ) b ) r e t u r n 1 ; 6 } 1 / q s o r t example / 2 #i n c l u d e <s t d i o. h> / p r i n t f / 3 #i n c l u d e <s t d l i b. h> / q s o r t / 5 i n t v a l u e s [ ] = { 0, 10, 100, 90, 20, 25 } ; 6 7 i n t compare ( c o n s t void a, c o n s t void b ) 8 { 9 r e t u r n ( ( i n t ) a ( i n t ) b ) ; 10 } i n t main ( ) 13 { 1 i n t n ; 15 q s o r t ( values, 6, s i z e o f ( i n t ), compare ) ; 16 f o r ( n=0; n<6; n++) 17 p r i n t f ( %d, v a l u e s [ n ] ) ; 18 r e t u r n 0 ; 19 } 10

11 Character handling: ctype.h Parameter for all functions below: Character to be converted, casted to an int, or EOF. Return value for all is-functions: A value different from zero (i.e., true) if indeed c is an alphabetic letter. Zero (i.e., false) otherwise..1 int isalnum ( int c ); Checks whether c is either a decimal digit or an uppercase or lowercase letter..2 int isalpha ( int c ); Checks whether c is an alphabetic letter..3 int isdigit ( int c ); Checks whether c is a decimal digit character.. int isprint ( int c ); Checks whether c is a printable character..5 int isspace ( int c ); Checks whether c is a white-space character..6 int tolower ( int c ); Converts c to its lowercase equivalent if c is an uppercase letter and has a lowercase equivalent. If no such conversion is possible, the value returned is c unchanged. The lowercase equivalent to c, if such value exists, or c (unchanged) otherwise..7 int toupper ( int c ); Converts c to its uppercase equivalent if c is a lowercase letter and has an uppercase equivalent. If no such conversion is possible, the value returned is c unchanged. The uppercase equivalent to c, if such value exists, or c (unchanged) otherwise. 11

12 5 Binary numbers Decimal pattern Hexadecimal pattern Binary pattern 0 0x x x x3 11 0x x x x x x xA xB xC xD xE xF Command line 6.1 First things to do Start command line, application named Terminal in Ubuntu. The folder that the command line opens by default is your home folder. Navigate to the correct folder (that has your code) with command cd (change directory). If you saved your code to your home directory, you do not need to use cd. You can get up one directory by using command cd.. and to your home directory with cd. 6.2 Compiling your program For compiling we use a tool called gcc. The parameters for gcc that are used when grading your program are -Wvla -Wall -g -std=c99. If you have for example two.c-files called main.c and program.c you would compile them to a executable file called program by the following command: gcc -Wvla -Wall -g -std=c99 -o program program.c main.c 6.3 Running your program After compiling successfully you could now run your program with command:./program 6. Using valgrind to check for memory errors To see that your program doesn t have any memory errors, run it under valgrind with the following command: valgrind --leak-check=full --track-origins=yes./program If you got ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0), then everything is fine, otherwise please check the output from valgrind to fix problems. 12

C Libraries. Bart Childs Complementary to the text(s)

C Libraries. Bart Childs Complementary to the text(s) C Libraries Bart Childs Complementary to the text(s) 2006 C was designed to make extensive use of a number of libraries. A great reference for student purposes is appendix B of the K&R book. This list

More information

Chapter 8 C Characters and Strings

Chapter 8 C Characters and Strings Chapter 8 C Characters and Strings Objectives of This Chapter To use the functions of the character handling library (). To use the string conversion functions of the general utilities library

More information

C: How to Program. Week /May/28

C: How to Program. Week /May/28 C: How to Program Week 14 2007/May/28 1 Chapter 8 - Characters and Strings Outline 8.1 Introduction 8.2 Fundamentals of Strings and Characters 8.3 Character Handling Library 8.4 String Conversion Functions

More information

Standard C Library Functions

Standard C Library Functions Demo lecture slides Although I will not usually give slides for demo lectures, the first two demo lectures involve practice with things which you should really know from G51PRG Since I covered much of

More information

Chapter 8 - Characters and Strings

Chapter 8 - Characters and Strings 1 Chapter 8 - Characters and Strings Outline 8.1 Introduction 8.2 Fundamentals of Strings and Characters 8.3 Character Handling Library 8.4 String Conversion Functions 8.5 Standard Input/Output Library

More information

C PROGRAMMING. Characters and Strings File Processing Exercise

C PROGRAMMING. Characters and Strings File Processing Exercise C PROGRAMMING Characters and Strings File Processing Exercise CHARACTERS AND STRINGS A single character defined using the char variable type Character constant is an int value enclosed by single quotes

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

Characters and Strings

Characters and Strings Characters and Strings 60-141: Introduction to Algorithms and Programming II School of Computer Science Term: Summer 2013 Instructor: Dr. Asish Mukhopadhyay Character constants A character in single quotes,

More information

Chapter 8: Character & String. In this chapter, you ll learn about;

Chapter 8: Character & String. In this chapter, you ll learn about; Chapter 8: Character & String Principles of Programming In this chapter, you ll learn about; Fundamentals of Strings and Characters The difference between an integer digit and a character digit Character

More information

Fundamentals of Programming. Lecture 11: C Characters and Strings

Fundamentals of Programming. Lecture 11: C Characters and Strings 1 Fundamentals of Programming Lecture 11: C Characters and Strings Instructor: Fatemeh Zamani f_zamani@ce.sharif.edu Sharif University of Technology Computer Engineering Department The lectures of this

More information

System Software Experiment 1 Lecture 7

System Software Experiment 1 Lecture 7 System Software Experiment 1 Lecture 7 spring 2018 Jinkyu Jeong ( jinkyu@skku.edu) Computer Systems Laboratory Sungyunkwan University http://csl.skku.edu SSE3032: System Software Experiment 1, Spring 2018

More information

Arrays, Strings, & Pointers

Arrays, Strings, & Pointers Arrays, Strings, & Pointers Alexander Nelson August 31, 2018 University of Arkansas - Department of Computer Science and Computer Engineering Arrays, Strings, & Pointers Arrays, Strings, & Pointers are

More information

Course organization. Course introduction ( Week 1)

Course organization. Course introduction ( Week 1) Course organization Course introduction ( Week 1) Code editor: Emacs Part I: Introduction to C programming language (Week 2-9) Chapter 1: Overall Introduction (Week 1-3) Chapter 2: Types, operators and

More information

C Characters and Strings

C Characters and Strings CS 2060 Character handling The C Standard Library provides many functions for testing characters in ctype.h. int isdigit(int c); // is c a digit (0-9)? int isalpha(int c); // is c a letter? int isalnum(int

More information

today cs3157-fall2002-sklar-lect05 1

today cs3157-fall2002-sklar-lect05 1 today homework #1 due on monday sep 23, 6am some miscellaneous topics: logical operators random numbers character handling functions FILE I/O strings arrays pointers cs3157-fall2002-sklar-lect05 1 logical

More information

C programming basics T3-1 -

C programming basics T3-1 - C programming basics T3-1 - Outline 1. Introduction 2. Basic concepts 3. Functions 4. Data types 5. Control structures 6. Arrays and pointers 7. File management T3-2 - 3.1: Introduction T3-3 - Review of

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

Scientific Programming in C V. Strings

Scientific Programming in C V. Strings Scientific Programming in C V. Strings Susi Lehtola 1 November 2012 C strings As mentioned before, strings are handled as character arrays in C. String constants are handled as constant arrays. const char

More information

Input / Output Functions

Input / Output Functions CSE 2421: Systems I Low-Level Programming and Computer Organization Input / Output Functions Presentation G Read/Study: Reek Chapter 15 Gojko Babić 10-03-2018 Input and Output Functions The stdio.h contain

More information

8. Characters, Strings and Files

8. Characters, Strings and Files REGZ9280: Global Education Short Course - Engineering 8. Characters, Strings and Files Reading: Moffat, Chapter 7, 11 REGZ9280 14s2 8. Characters and Arrays 1 ASCII The ASCII table gives a correspondence

More information

C Programming. Unit 9. Manipulating Strings File Processing.

C Programming. Unit 9. Manipulating Strings File Processing. Introduction to C Programming Unit 9 Manipulating Strings File Processing skong@itt-tech.edu Unit 8 Review Unit 9: Review of Past Material Unit 8 Review Arrays Collection of adjacent memory cells Each

More information

SWEN-250 Personal SE. Introduction to C

SWEN-250 Personal SE. Introduction to C SWEN-250 Personal SE Introduction to C A Bit of History Developed in the early to mid 70s Dennis Ritchie as a systems programming language. Adopted by Ken Thompson to write Unix on a the PDP-11. At the

More information

UNIT IV-2. The I/O library functions can be classified into two broad categories:

UNIT IV-2. The I/O library functions can be classified into two broad categories: UNIT IV-2 6.0 INTRODUCTION Reading, processing and writing of data are the three essential functions of a computer program. Most programs take some data as input and display the processed data, often known

More information

ch = argv[i][++j]; /* why does ++j but j++ does not? */

ch = argv[i][++j]; /* why does ++j but j++ does not? */ CMPS 12M Introduction to Data Structures Lab Lab Assignment 4 The purpose of this lab assignment is to get more practice programming in C, including the character functions in the library ctype.h, and

More information

File IO and command line input CSE 2451

File IO and command line input CSE 2451 File IO and command line input CSE 2451 File functions Open/Close files fopen() open a stream for a file fclose() closes a stream One character at a time: fgetc() similar to getchar() fputc() similar to

More information

Muntaser Abulafi Yacoub Sabatin Omar Qaraeen. C Data Types

Muntaser Abulafi Yacoub Sabatin Omar Qaraeen. C Data Types Programming Fundamentals for Engineers 0702113 5. Basic Data Types Muntaser Abulafi Yacoub Sabatin Omar Qaraeen 1 2 C Data Types Variable definition C has a concept of 'data types' which are used to define

More information

Standard File Pointers

Standard File Pointers 1 Programming in C Standard File Pointers Assigned to console unless redirected Standard input = stdin Used by scan function Can be redirected: cmd < input-file Standard output = stdout Used by printf

More information

A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called.

A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called. Chapter-12 FUNCTIONS Introduction A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called. Types of functions There are two types

More information

CS 261 Fall Mike Lam, Professor. Structs and I/O

CS 261 Fall Mike Lam, Professor. Structs and I/O CS 261 Fall 2018 Mike Lam, Professor Structs and I/O Typedefs A typedef is a way to create a new type name Basically a synonym for another type Useful for shortening long types or providing more meaningful

More information

211: Computer Architecture Summer 2016

211: Computer Architecture Summer 2016 211: Computer Architecture Summer 2016 Liu Liu Topic: C Programming Data Representation I/O: - (example) cprintf.c Memory: - memory address - stack / heap / constant space - basic data layout Pointer:

More information

MARKS: Q1 /20 /15 /15 /15 / 5 /30 TOTAL: /100

MARKS: Q1 /20 /15 /15 /15 / 5 /30 TOTAL: /100 FINAL EXAMINATION INTRODUCTION TO ALGORITHMS AND PROGRAMMING II 03-60-141-01 U N I V E R S I T Y O F W I N D S O R S C H O O L O F C O M P U T E R S C I E N C E Winter 2014 Last Name: First Name: Student

More information

Procedural Programming

Procedural Programming Exercise 5 (SS 2016) 28.06.2016 What will I learn in the 5. exercise Strings (and a little bit about pointer) String functions in strings.h Files Exercise(s) 1 Home exercise 4 (3 points) Write a program

More information

by Pearson Education, Inc. All Rights Reserved.

by Pearson Education, Inc. All Rights Reserved. The string-handling library () provides many useful functions for manipulating string data (copying strings and concatenating strings), comparing strings, searching strings for characters and

More information

Contents. Preface. Introduction. Introduction to C Programming

Contents. Preface. Introduction. Introduction to C Programming c11fptoc.fm Page vii Saturday, March 23, 2013 4:15 PM Preface xv 1 Introduction 1 1.1 1.2 1.3 1.4 1.5 Introduction The C Programming Language C Standard Library C++ and Other C-Based Languages Typical

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features

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

Strings(2) CS 201 String. String Constants. Characters. Strings(1) Initializing and Declaring String. Debzani Deb

Strings(2) CS 201 String. String Constants. Characters. Strings(1) Initializing and Declaring String. Debzani Deb CS 201 String Debzani Deb Strings(2) Two interpretations of String Arrays whose elements are characters. Pointer pointing to characters. Strings are always terminated with a NULL characters( \0 ). C needs

More information

Converting a Lowercase Letter Character to Uppercase (Or Vice Versa)

Converting a Lowercase Letter Character to Uppercase (Or Vice Versa) Looping Forward Through the Characters of a C String A lot of C string algorithms require looping forward through all of the characters of the string. We can use a for loop to do that. The first character

More information

ENG120. Misc. Topics

ENG120. Misc. Topics ENG120 Misc. Topics Topics Files in C Using Command-Line Arguments Typecasting Working with Multiple source files Conditional Operator 2 Files and Streams C views each file as a sequence of bytes File

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

Strings. Arrays of characters. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY

Strings. Arrays of characters. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY Strings Arrays of characters Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY 1 Basics Strings A string is a sequence of characters treated as a group We have already

More information

Characters, c-strings, and the string Class. CS 1: Problem Solving & Program Design Using C++

Characters, c-strings, and the string Class. CS 1: Problem Solving & Program Design Using C++ Characters, c-strings, and the string Class CS 1: Problem Solving & Program Design Using C++ Objectives Perform character checks and conversions Knock down the C-string fundamentals Point at pointers and

More information

Computer Programming

Computer Programming Computer Programming Make everything as simple as possible, but not simpler. Albert Einstein T.U. Cluj-Napoca - Computer Programming - lecture 4 - M. Joldoş 1 Outline Functions Structure of a function

More information

Systems Programming. 08. Standard I/O Library. Alexander Holupirek

Systems Programming. 08. Standard I/O Library. Alexander Holupirek Systems Programming 08. Standard I/O Library Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of Konstanz Summer Term 2008 Last lecture:

More information

Signature: ECE 551 Midterm Exam

Signature: ECE 551 Midterm Exam Name: ECE 551 Midterm Exam 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 work.

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e Storage of data in variables and arrays is temporary such data is lost when a program terminates. Files are used for permanent retention of data. Computers store files on secondary

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

Introduction to C/C++ Lecture 5 - String & its Manipulation

Introduction to C/C++ Lecture 5 - String & its Manipulation Introduction to C/C++ Lecture 5 - String & its Manipulation Rohit Sehgal Nishit Majithia Association of Computing Activities, Indian Institute of Technology,Kanpur rsehgal@cse.iitk.ac.in nishitm@cse.iitk.ac.in

More information

System Design and Programming II

System Design and Programming II System Design and Programming II CSCI 194 Section 01 CRN: 10968 Fall 2017 David L. Sylvester, Sr., Assistant Professor Chapter 10 Characters, Strings, and the string Class Character Testing The C++ library

More information

C strings. (Reek, Ch. 9) 1 CS 3090: Safety Critical Programming in C

C strings. (Reek, Ch. 9) 1 CS 3090: Safety Critical Programming in C C strings (Reek, Ch. 9) 1 Review of strings Sequence of zero or more characters, terminated by NUL (literally, the integer value 0) NUL terminates a string, but isn t part of it important for strlen()

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 13 si 14: Unix interface for working with files. Cristina Nita-Rotaru Lecture 13/Fall 2013 1 Working with Files (I/O) File system: specifies how the information is organized

More information

Introduction to string

Introduction to string 1 Introduction to string String is a sequence of characters enclosed in double quotes. Normally, it is used for storing data like name, address, city etc. ASCII code is internally used to represent string

More information

ECE551 Midterm. There are 7 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly.

ECE551 Midterm. There are 7 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly. Name: ECE551 Midterm 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 work. You

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

Input/Output and the Operating Systems

Input/Output and the Operating Systems Input/Output and the Operating Systems Fall 2015 Jinkyu Jeong (jinkyu@skku.edu) 1 I/O Functions Formatted I/O printf( ) and scanf( ) fprintf( ) and fscanf( ) sprintf( ) and sscanf( ) int printf(const char*

More information

Files and Streams Opening and Closing a File Reading/Writing Text Reading/Writing Raw Data Random Access Files. C File Processing CS 2060

Files and Streams Opening and Closing a File Reading/Writing Text Reading/Writing Raw Data Random Access Files. C File Processing CS 2060 CS 2060 Files and Streams Files are used for long-term storage of data (on a hard drive rather than in memory). Files and Streams Files are used for long-term storage of data (on a hard drive rather than

More information

Outline. Computer Programming. Structure of a function. Functions. Function prototype. Structure of a function. Functions

Outline. Computer Programming. Structure of a function. Functions. Function prototype. Structure of a function. Functions Outline Computer Programming Make everything as simple as possible, but not simpler. Albert Einstein Functions Structure of a function Function invocation Parameter passing Functions as parameters Variable

More information

Strings and Library Functions

Strings and Library Functions Unit 4 String String is an array of character. Strings and Library Functions A string variable is a variable declared as array of character. The general format of declaring string is: char string_name

More information

7/21/ FILE INPUT / OUTPUT. Dong-Chul Kim BioMeCIS UTA

7/21/ FILE INPUT / OUTPUT. Dong-Chul Kim BioMeCIS UTA 7/21/2014 1 FILE INPUT / OUTPUT Dong-Chul Kim BioMeCIS CSE @ UTA What s a file? A named section of storage, usually on a disk In C, a file is a continuous sequence of bytes Examples for the demand of a

More information

Introduction to file management

Introduction to file management 1 Introduction to file management Some application require input to be taken from a file and output is required to be stored in a file. The C language provides the facility of file input-output operations.

More information

Announcements. Strings and Pointers. Strings. Initializing Strings. Character I/O. Lab 4. Quiz. July 18, Special character arrays

Announcements. Strings and Pointers. Strings. Initializing Strings. Character I/O. Lab 4. Quiz. July 18, Special character arrays Strings and Pointers Announcements Lab 4 Why are you taking this course? Lab 5 #, 8: Reading in data from file using fscanf Quiz Quiz Strings Special character arrays End in null character, \ char hi[6];

More information

Accessing Files in C. Professor Hugh C. Lauer CS-2303, System Programming Concepts

Accessing Files in C. Professor Hugh C. Lauer CS-2303, System Programming Concepts Accessing Files in C Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter

More information

Mode Meaning r Opens the file for reading. If the file doesn't exist, fopen() returns NULL.

Mode Meaning r Opens the file for reading. If the file doesn't exist, fopen() returns NULL. Files Files enable permanent storage of information C performs all input and output, including disk files, by means of streams Stream oriented data files are divided into two categories Formatted data

More information

ECE 551D Spring 2018 Midterm Exam

ECE 551D Spring 2018 Midterm Exam Name: SOLUTIONS 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

More information

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3).

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3). cs3157: another C lecture (mon-21-feb-2005) C pre-processor (1). today: C pre-processor command-line arguments more on data types and operators: booleans in C logical and bitwise operators type conversion

More information

Structured programming

Structured programming Exercises 10 Version 1.0, 13 December, 2016 Table of Contents 1. Strings...................................................................... 1 1.1. Remainders from lectures................................................

More information

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition ELEC / COMP 177 Fall 2012 Some slides from Kurose and Ross, Computer Networking, 5 th Edition Prior experience in programming languages C++ programming? Java programming? C programming? Other languages?

More information

File I/O. Arash Rafiey. November 7, 2017

File I/O. Arash Rafiey. November 7, 2017 November 7, 2017 Files File is a place on disk where a group of related data is stored. Files File is a place on disk where a group of related data is stored. C provides various functions to handle files

More information

ONE DIMENSIONAL ARRAYS

ONE DIMENSIONAL ARRAYS LECTURE 14 ONE DIMENSIONAL ARRAYS Array : An array is a fixed sized sequenced collection of related data items of same data type. In its simplest form an array can be used to represent a list of numbers

More information

Chapter 12. Files (reference: Deitel s chap 11) chap8

Chapter 12. Files (reference: Deitel s chap 11) chap8 Chapter 12 Files (reference: Deitel s chap 11) 20061025 chap8 Introduction of File Data files Can be created, updated, and processed by C programs Are used for permanent storage of large amounts of data

More information

Appendix A Developing a C Program on the UNIX system

Appendix A Developing a C Program on the UNIX system Appendix A Developing a C Program on the UNIX system 1. Key in and save the program using vi - see Appendix B - (or some other editor) - ensure that you give the program file a name ending with.c - to

More information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 07: Data Input and Output Readings: Chapter 4 Input /Output Operations A program needs

More information

CS3157: Advanced Programming. Outline

CS3157: Advanced Programming. Outline CS3157: Advanced Programming Lecture #8 Feb 27 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline More c Preprocessor Bitwise operations Character handling Math/random Review for midterm Reading: k&r ch

More information

CSC209H Lecture 3. Dan Zingaro. January 21, 2015

CSC209H Lecture 3. Dan Zingaro. January 21, 2015 CSC209H Lecture 3 Dan Zingaro January 21, 2015 Streams (King 22.1) Stream: source of input or destination for output We access a stream through a file pointer (FILE *) Three streams are available without

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

CSCE150A. Introduction. Basics. String Library. Substrings. Line Scanning. Sorting. Command Line Arguments. Misc CSCE150A. Introduction.

CSCE150A. Introduction. Basics. String Library. Substrings. Line Scanning. Sorting. Command Line Arguments. Misc CSCE150A. Introduction. Chapter 9 Scanning Computer Science & Engineering 150A Problem Solving Using Computers Lecture 07 - Strings Stephen Scott (Adapted from Christopher M. Bourke) Scanning 9.1 String 9.2 Functions: Assignment

More information

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

More information

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 9. Strings. Notes. Notes. Notes. Lecture 07 - Strings

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 9. Strings. Notes. Notes. Notes. Lecture 07 - Strings Computer Science & Engineering 150A Problem Solving Using Computers Lecture 07 - Strings Scanning Stephen Scott (Adapted from Christopher M. Bourke) 1 / 51 Fall 2009 cbourke@cse.unl.edu Chapter 9 Scanning

More information

Computer Language. It is a systematical code for communication between System and user. This is in two categories.

Computer Language. It is a systematical code for communication between System and user. This is in two categories. ComputerWares There are 3 types of Computer wares. 1. Humanware: The person, who can use the system, is called 'Human Ware ". He is also called as "User". Users are in two types: i. Programmer: The person,

More information

Reading Assignment. Strings. K.N. King Chapter 13. K.N. King Sections 23.4, Supplementary reading. Harbison & Steele Chapter 12, 13, 14

Reading Assignment. Strings. K.N. King Chapter 13. K.N. King Sections 23.4, Supplementary reading. Harbison & Steele Chapter 12, 13, 14 Reading Assignment Strings char identifier [ size ] ; char * identifier ; K.N. King Chapter 13 K.N. King Sections 23.4, 23.5 Supplementary reading Harbison & Steele Chapter 12, 13, 14 Strings are ultimately

More information

Advanced C Programming Topics

Advanced C Programming Topics Introductory Medical Device Prototyping Advanced C Programming Topics, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Operations on Bits 1. Recall there are 8

More information

CS246 Spring14 Programming Paradigm Files, Pipes and Redirection

CS246 Spring14 Programming Paradigm Files, Pipes and Redirection 1 Files 1.1 File functions Opening Files : The function fopen opens a file and returns a FILE pointer. FILE *fopen( const char * filename, const char * mode ); The allowed modes for fopen are as follows

More information

Input/Output: Advanced Concepts

Input/Output: Advanced Concepts Input/Output: Advanced Concepts CSE 130: Introduction to Programming in C Stony Brook University Related reading: Kelley/Pohl 1.9, 11.1 11.7 Output Formatting Review Recall that printf() employs a control

More information

C Syntax Arrays and Loops Math Strings Structures Pointers File I/O. Final Review CS Prof. Jonathan Ventura. Prof. Jonathan Ventura Final Review

C Syntax Arrays and Loops Math Strings Structures Pointers File I/O. Final Review CS Prof. Jonathan Ventura. Prof. Jonathan Ventura Final Review CS 2060 Variables Variables are statically typed. Variables must be defined before they are used. You only specify the type name when you define the variable. int a, b, c; float d, e, f; char letter; //

More information

LSN 3 C Concepts for OS Programming

LSN 3 C Concepts for OS Programming LSN 3 C Concepts for OS Programming ECT362 Operating Systems Department of Engineering Technology LSN 3 C Programming (Review) Numerical operations Punctuators ( (), {}) Precedence and Association Mixed

More information

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types

More information

Basic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Announcements Exam 1 (20%): Feb. 27 (Tuesday) Tentative Proposal Deadline:

More information

CSci 4061 Introduction to Operating Systems. Input/Output: High-level

CSci 4061 Introduction to Operating Systems. Input/Output: High-level CSci 4061 Introduction to Operating Systems Input/Output: High-level I/O Topics First, cover high-level I/O Next, talk about low-level device I/O I/O not part of the C language! High-level I/O Hide device

More information

Fundamentals of Programming & Procedural Programming

Fundamentals of Programming & Procedural Programming Universität Duisburg-Essen PRACTICAL TRAINING TO THE LECTURE Fundamentals of Programming & Procedural Programming Session Seven: Strings and Files Name: First Name: Tutor: Matriculation-Number: Group-Number:

More information

Computer Science & Engineering 150A Problem Solving Using Computers

Computer Science & Engineering 150A Problem Solving Using Computers Computer Science & Engineering 150A Problem Solving Using Computers Lecture 07 - Strings Stephen Scott (Adapted from Christopher M. Bourke) 1 / 51 Fall 2009 Chapter 9 9.1 String 9.2 Functions: Assignment

More information

Kurt Schmidt. October 30, 2018

Kurt Schmidt. October 30, 2018 to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed

More information

Quick review of previous lecture Ch6 Structure Ch7 I/O. EECS2031 Software Tools. C - Structures, Unions, Enums & Typedef (K&R Ch.

Quick review of previous lecture Ch6 Structure Ch7 I/O. EECS2031 Software Tools. C - Structures, Unions, Enums & Typedef (K&R Ch. 1 Quick review of previous lecture Ch6 Structure Ch7 I/O EECS2031 Software Tools C - Structures, Unions, Enums & Typedef (K&R Ch.6) Structures Basics: Declaration and assignment Structures and functions

More information

High Performance Programming Programming in C part 1

High Performance Programming Programming in C part 1 High Performance Programming Programming in C part 1 Anastasia Kruchinina Uppsala University, Sweden April 18, 2017 HPP 1 / 53 C is designed on a way to provide a full control of the computer. C is the

More information

CSI 402 Lecture 2 Working with Files (Text and Binary)

CSI 402 Lecture 2 Working with Files (Text and Binary) CSI 402 Lecture 2 Working with Files (Text and Binary) 1 / 30 AQuickReviewofStandardI/O Recall that #include allows use of printf and scanf functions Example: int i; scanf("%d", &i); printf("value

More information

Getting Started. Project 1

Getting Started. Project 1 Getting Started Project 1 Project 1 Implement a shell interface that behaves similarly to a stripped down bash shell Due in 3 weeks September 21, 2015, 11:59:59pm Specification, grading sheet, and test

More information

CS107 Spring 2019, Lecture 4 C Strings

CS107 Spring 2019, Lecture 4 C Strings CS107 Spring 2019, Lecture 4 C Strings Reading: K&R (1.9, 5.5, Appendix B3) or Essential C section 3 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative

More information

Content. Input Output Devices File access Function of File I/O Redirection Command-line arguments

Content. Input Output Devices File access Function of File I/O Redirection Command-line arguments File I/O Content Input Output Devices File access Function of File I/O Redirection Command-line arguments UNIX and C language C is a general-purpose, high-level language that was originally developed by

More information

CSE 12 Spring 2016 Week One, Lecture Two

CSE 12 Spring 2016 Week One, Lecture Two CSE 12 Spring 2016 Week One, Lecture Two Homework One and Two: hw2: Discuss in section today - Introduction to C - Review of basic programming principles - Building from fgetc and fputc - Input and output

More information

File Handling in C. EECS 2031 Fall October 27, 2014

File Handling in C. EECS 2031 Fall October 27, 2014 File Handling in C EECS 2031 Fall 2014 October 27, 2014 1 Reading from and writing to files in C l stdio.h contains several functions that allow us to read from and write to files l Their names typically

More information

C Basics And Concepts Input And Output

C Basics And Concepts Input And Output C Basics And Concepts Input And Output Report Working group scientific computing Department of informatics Faculty of mathematics, informatics and natural sciences University of Hamburg Written by: Marcus

More information