C language-Standard Functions

Source: Internet
Author: User

Introduce function package

#include "stdio.h"#include "string.h"

In tc2.0, the header file of the library function is in the TC/include directory, and the system function is in the TC/lib directory. If these function files cannot be found, you can perform the following settings in option/directories:

Include directories {TC2 directory}/includeinclude directories {TC2 directory}/lib

1. Standard Input/Output Functions

Introduce the header file stdio. h

Input Device: Mouse, keyboard, camera, etc.

Output devices: files, screens, empty devices (NUL), etc.

Input Function: scanf ()

Output Function: printf ()

2-character functions and string processing functions

Character function file: ctype. H. It is mainly used to identify ASCII letters, control characters, punctuation marks, and case-sensitivity conversion.

String function file: String. H. It is mainly used for string copying, connection, searching, and substring processing.

/* Character Statistics */# include <stdio. h> # include <math. h> main () {int num = 0, cntrl_num = 0, else_num = 0; char ch; printf ("character statistics/n "); printf ("Enter the character (CTRL + Z):"); While (CH = getchar ())! = EOF) {If (iscntrl (CH) {/* determine whether it is a control character */cntrl_num ++;} else if (isdigit (CH )) {/* determine whether it is a number */num ++;} else {/* Other characters */else_num ++ ;}} printf ("control characters: % d/N", cntrl_num); printf ("number: % d/N", num ); printf ("other characters include % d/N", else_num );}

In the program, the getchar () function is used to obtain a character input from the keyboard. EOF is a constant (EOF =-1) defined in stdio. H. It is usually used to determine whether the file has ended. Press the keyboard to enter the time table Ctrl + z key combination.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.