String standard functions


Functions
Description
Strlen()
Determines the length of a string
Strcpy()
Copies  a string from source to destination
Strncpy()
Copies characters of a string to another string up to the specified length
Stricmp()
Compares characters of two strings
Strcmp()
Compares characters of two strings up to the specified length
Strncmp()
Compares characters of two strings up to the specified length
Strnicmp()
Compares characters of two strings up to the specified length
Strlwr()
Converts uppercase characters of a string to lower case
Strupr()
Converts lowercase characters of a string to upper case
Strdup()
Duplicates a string
Strchr()
Determines the first occurrence of a given character in a string
Strrchr()
Determines the last occurrence of a given character in a string
Strstr()
Determines the first occurrence of a given string in another string
Strcat()
Appends source string to destination string
Strrev()
Reverses all characters of a string
Strset()
Sets all characters of a string with a given argument or symbol
Strspn()
Finds up to what length two strings are identical
Strpbrk()
Searches the first occurrence of the character in a given string and then displays the string starting from that character

sprintf()


This function is similar to the printf() function except for a small difference between them. The printf() function sends the output to the screen whereas the sprint() function writes the values of any data type to an array of characters. 

sscanf()


This function allows reading characters from a character array and writes them to another array. This function is similar to scanf(), but instead of reading from standard input it reads data from an array. 

Add Comments in C



Load the file comments.c and observe it on your monitor for an example of how comments
can be added to a C program.




/* This is a comment ignored by the compiler */
main( ) /* This is another comment ignored by the compiler */
{
printf("We are looking at how comments are "); /* A comment is
allowed to be
continued on
another line */
2-3 C Tutorial Getting started in C
printf("used in C.\n");
}
/* One more comment for effect */






Comments are added to make a program more readable to you but the compiler must ignore the comments. The slash star combination is used inC for comment delimiters. They are illustrated in the program at hand. Please note that the program does not illustrate good commenting practice, but is intended to illustrate where comments can go in a program. It is a very sloppy looking program. The first slash star combination introduces the first comment and the star at the end of the first line terminates this comment. Note that this comment is prior to the beginning of the program illustrating that a comment can precede the program itself. Good programming practice would include a comment prior to the program with a short introductory description of the program. The next comment is after the "main( )" program entry point and prior to the opening brace for the program code itself. The third comment starts after the first executable statement and continue for four lines. This is perfectly legal because a comment can continue for as many lines as desired until it is terminated. Note carefully that if anything were included in the blank spaces to the left of the three
continuation lines of the comment, it would be part of the comment and would not be compiled. The last comment is located following the completion of the program, illustrating that comments can go nearly anywhere in a C program. Experiment with this program be adding comments in other places to see what will happen. Comment out one of the printf statements by putting comment delimiters both before and after it and see that it does not get printed out.
Comments are very important in any programming language because you will soon forget what you did and why you did it. It will be much easier to modify or fix a well commented program
a year from now than one with few or no comments. You will very quickly develop your own personal style of commenting.
Somecompilers allow you to "nest" comments which can be very handy if you need to "comment out" a section of code during debugging. Check your compiler documentation for the availability of this feature with your particular compiler. Compile and run comments.c at this time.