标签:
嗯,受人所托,顺便整理的
英文渣
侵删。
// 注释的部分是解说(废话)和不怎么重(kǎo)要(chá)的
错误请指正
#include <stdio.h> #include <string.h> int main() { char str[] = "sstr"; // "sstr." == ‘s‘, ‘s‘, ‘t‘, ‘r‘, ‘\0‘ // without a ‘\0‘ it‘s usually not considered a c-style string // but a normal array of type char // many lib funcs need ‘\0‘ to identify a complete string
printf("%s\n", sstr); scanf("%s", sstr); // stops reading when meets a space printf("\n%s\n", sstr); gets(str); // reads a full line until a ‘\n‘ // (‘\n‘ not included) // puts(char[]) is less used, automatically ‘\n‘ int len = strlen(sstr); // ‘\0‘ not included // strcat(aimStr, sourceStr); // 2 ‘\0‘ needed and 1 remains // strcat(aimStr, sourceStr, n); // only n bytes // strcpy(aimStr, sourceStr (, n)); // strcmp(strA, strB (, n)); // strA-strB (the first n bits) // ascii bigger, string bigger // the longer, the bigger // strlwr(sstr); strupr(sstr); newStr = strstr(char* text, char* match); // char* arrayAddress = strrev(sstr); // strset etc, recommeding memset(void* _Dst, int _Val, size_t _Size); // mem.h or string.h double doublePrecision = strtod(strFloat, &endptr); // atoi,atol,strtod,strtol,strtoul // proto: longstrtol(char *str, char **endptr, int base); // for io c = getchar(); // dangerous, ‘\n‘ and all asciis untouched gets(sstr); // ‘\n‘ is read and replaced by ‘\0‘ scanf(... , someStr) // buf still holds ‘\n‘, ‘ ‘, etc scanf(... , &someChar) // close to getchar() // for formatted io, related sources: // http://www.jb51.net/article/62358.htm // http://baike.baidu.com/link?url=Ijwdh1w3qXfTtff-WlPW1QowBiaCgE7zjVHAOT35VHDXtmz3MmQhPk7zs-_pc1_7rI9-AZRZr60hWlgzPeUzQa // focus: operator precedence // file io is important but not in the range }
by(无‘\0‘)
by 百毒百科
标签:
原文地址:http://www.cnblogs.com/witchelny-ravens/p/5077295.html