week 2 c programming code Flashcards
to learn more about c programming
what is a string in c#
string of characters is a 1D array of characters
how much memory does ASCII store
(1 byte) of each character element is stored in
consecutive memory locations
what is string terminated by
String is terminated by the null character ‘\0’ (ASCII value 0)
what is the length of the null string
The null string (length zero) is the null character only
what is use to take input from user in c#
scanf()
what is used to output info to user
printf()
what is the format for string in c
%s
what is the 4 safe string functions
strcpy()
strcat()
strlen()
strcmp
what is strcpy()
copies the string from one destination to another
what do you need to make sure that you do in strcpy()
need to allocate memory to the destination where you want to put your string
e.g
char[10] destination; -> where i will put the string in;
what does strlen do
gets the length of the string;
does strlen take into account the null value
no
what does strcat do
concatenates 2 strings together
in strcat(str1,str2) which string is modified and which stays the same
str2 stays the same and str1 changes as str2 is appended to teh end of str1
what does strcmp do
compares 2 strings and see if they are the same