Coding
  • Welcome
  • Baisc Knowledge
    • Vim
    • C
      • Library
    • Java
      • Setup
      • Java Basic
  • Kattis
    • Easy
      • A Second Opinion
      • A Shortcut to What?
      • A Stack of Gold
      • ACM Contest Scoring
      • ASCII kassi
      • Aaah!
      • Add Two Numbers
      • Adding Trouble
      • Afjörmun
      • Airfare Grants
      • Above Average
      • Akcija
      • Alphabet Spam
      • Amerískur vinnustaður
      • Anti-Palindrome
      • Apaxiaaaaaaaaaaaans!
      • Arithmetic Functions
      • Arm Coordination
      • Arrangement
      • Attendance
      • Autori
      • Average Character
      • Avion
      • Baby Bites
      • Babylonian Numbers
      • ABC
      • Aldur
      • Backspace
      • Bannorð
      • Barcelona
      • Basketball One-on-One
      • Batter Up
      • Beavergnaw
      • Bela
      • BergMál
      • Bergur*
      • Akureyri*
      • Best Compromise
      • Best Relay Team*
      • Besta gjöfin
      • Betting
      • Bijele
      • Bilað Lyklaborð
      • Bitte ein Bit
      • Blandað Best
      • Blaðra
      • Blaðra2
      • Bluetooth*
      • Booking a Room
      • Bottle Opening
      • Bounding Robots
      • Breaking Branches*
      • Bracket Matching*
      • Broken Swords
      • Building Pyramids
      • Bus
      • Bus Assignment
      • CPR Number
      • Call for Problems
      • Canadians, eh?
      • Candy Store
      • Cetiri
      • Cetvrta
      • Champernowne Verification
      • Chanukah Challenge
      • Chardonnay
      • Chocolate Division*
      • Chugging
      • Cinema Crowds 2
      • Class Field Trip
      • ASCII Kassi 2
      • Coffee Cup Combo
      • Cold-puter Science
      • Composed Rhythms
      • Cookies
      • Cooking Water
      • Cornhusker
      • Cosmic Path Optimization
      • Count the Vowels
Powered by GitBook
On this page
  • CS1010 Library
  • C Standard Library
  • Table
Edit on GitHub
  1. Baisc Knowledge
  2. C

Library

PreviousCNextJava

Last updated 6 months ago

CS1010 Library

The CS1010 input and output library can be found below:

To use the library on your local pc, please follow this .

C Standard Library

The best way to see how to use a standard libarary function in C is to use Linux Programmer's Manual. The command used is man <function_name>.

Table

string.h

Name
Description
Return Values

int strcmp(const char *s1, const char *s2);

The strcmp() function compares the two strings s1 and s2.

  • 0, if s1 and s2 are equal

  • a negative value if s1 is less than s2

  • a positive value if s1 is bigger than s2

size_t strspn(const char *s, const char *accept);

The strspn() function calculates the length (in bytes) of the initial segment of s which consists entirely of bytes in accept.

The strspn() function returns the number of bytes in the initial segment of s which consist only of bytes from accept.

size_t strcspn(const char *s, const char *reject);

The strcspn() function calculates the length of the initial segment of s which consists entirely of bytes not in reject.

The strcspn() function returns the number of bytes in the initial segment of s which are not in the string reject.

char *strstr(const char *haystack, const char *needle);

The strstr() function finds the first occurrence of the substring needle in the string haystack. The terminating null bytes ('\0') are not compared.

This function return a pointer to the beginning of the located substring, or NULL if the substring is not found.

char *strcasestr(const char *haystack, const char *needle);

The strcasestr() function is like strstr(), but ignores the case of both arguments.

This function return a pointer to the beginning of the located substring, or NULL if the substring is not found.

char *strchr(const char *s, int c);

The strchr() function returns a pointer to the first occurrence of the character c in the string s.

The strchr() function returns a pointer to the matched character or NULL if the character is not found. The terminating null byte is considered part of the string, so that if c is specified as '\0', the function returns a pointer to the terminator.

char *strrchr(const char *s, int c);

The strrchr() function returns a pointer to the last occurrence of the character c in the string s.

The strrchr() function return a pointer to the matched character or NULL if the character is not found. The terminating null byte is considered part of the string, so that if c is specified as '\0', the function returns a pointer to the terminator.

stdlib.h

Name
Description
Return Values

void free(void *ptr);

The free() function frees the memory space pointed to by ptr, which must have been returned by a previous call to malloc(), calloc(), or realloc(). Otherwise, or if free(ptr) has already been called before, undefined behavior occurs. If ptr is NULL, no operation is performed.

The free() function returns no value.

guide
https://github.com/nus-cs1010/libcs1010