字符串库函数的使用(2pg)
pg ifnull函数

pg ifnull函数
pgifnull函数是一种在PostgreSQL数据库中用于处理空值的函数。
在SQL中,如果一个列或表达式的值为空,那么它会导致查询结果出现错误或异常。
使用ifnull函数可以避免这种情况,它可以将空值转换为指定的默认值或空字符串。
pg ifnull函数语法如下:
ifnull(expression, value)
其中,expression是要检查的表达式,value是当expression 为空时返回的默认值。
如果expression不为空,则返回expression 的值。
例如,如果需要将空值转换为空字符串,可以使用以下语句: SELECT ifnull(username, '') FROM users;
如果username列中的值为空,则返回空字符串。
如果不为空,则返回username的值。
需要注意的是,ifnull函数只适用于PostgreSQL数据库,其他数据库可能使用不同的函数或语法来处理空值。
- 1 -。
pg replace用法

pg replace用法
PostgreSQL的replace函数是一个用于替换字符串中的字母,数字或者符号的函数。
它也可以用于简单的查找和替换应用程序中的文本。
replace函数的语法如下:
REPLACE(原字符串,查找字符串,替换字符串)
下面来详细说明REPLACE函数的用法:
1. 原字符串:REPLACE函数开始搜索都从这里开始,这个字段必须指定,不能为空。
2. 查找字符串:这一字段表示要查找的单词或字符串,如果查找字符串为空,那么replace函数仅仅可以从原字符串中删除它。
3. 替换字符串:替换字符串可以是一个较短的字符串,也可以是一个长字符串,甚至可以是一个空字符串,空的就会删除找到的字段。
在实际的使用中,替换字符串可以是任意形式,可以为字符,也可以为字符串。
REPLACE函数是一个非常有用的函数,它可以替换我们指定的字符串中的某个字符,数字,或者符号,从而获取我们想要的输出结果。
因此,REPLACE函数在数据库应用开发中发挥着重要的作用。
Postgresql数据库的一些字符串操作函数

Postgresql数据库的⼀些字符串操作函数 今天做项⽬遇到客户反映了⼀个⿇烦的事情,有⼀些数据存在,但就是在程序中搜索不出来,后来分析,发现问题为数据前⾯有⼏个空⽩字符,后来⽤SQL查询了⼀下,发现⼋九个数据表中,数千万条数据中有将近三百万条数据存在相同的问题,本想着在查询时添加匹配符'%',后来试运⾏了⼀下,发现不可⾏,因为尚有很多其它页⾯存在类似的搜索问题,并且这样会极⼤地影响到查询的速度,再加上客户迫切需要解决这个问题,由于在⽩天程序需不间断访问,并且不能对其运⾏速度产⽣较⼤的影响,所以排除了JDBC进⾏修改的⽅案,也排除了修改程序搜索代码的⽅案,头痛不⼰ 后来仔细想了⼀下,并尝试去查找相关sql字符串操作函数,确认有没有快捷的⽅式去解决空⽩字符串问题,很快,我们找到了合适的解决⽅案,对其中⼀个测试数据库进⾏了测试,结果⾮常令⼈满意,三百多万的数据只⽤了数分种,便去掉了所有的⽆⽤空格问题,为之兴奋不⼰。
⽤法如下update property set memorial_no = btrim(memorial_no, ' ') where memorial_no like ' %'或update property set memorial_no = trim(both ' ' from memorial_no) where memorial_no like ' %'btrim()⽅法为删除字符串两边的某类字符,可以同时指定多个,在上⾯为' ',意为空格trim()⽅法可以实现所有btrim()能实现的功能,事实上btrim()即为删除两边的某类字符串,trim()可以只指定某⼀边,当然也可以为两边 现把Postgresql的字符串操作函数罗列在以,以便⽇⽅使⽤函数:string || string 说明:String concatenation 字符串连接操作例⼦:'Post' || 'greSQL' = PostgreSQL函数:string || non-string or non-string || string说明:String concatenation with one non-string input 字符串与⾮字符串类型进⾏连接操作例⼦:'Value: ' || 42 = Value: 42函数:bit_length(string)说明:Number of bits in string 计算字符串的位数例⼦:bit_length('jose') = 32函数:char_length(string) or character_length(string)说明:Number of characters in string 计算字符串中字符个数例⼦:char_length('jose') = 4函数:lower(string)说明:Convert string to lower case 转换字符串为⼩写例⼦:bit_length('jose') = 32函数:octet_length(string)说明:Number of bytes in string 计算字符串的字节数例⼦:octet_length('jose') = 4函数:overlay(string placing string from int [for int])说明:Replace substring 替换字符串中任意长度的⼦字串为新字符串例⼦:overlay('Txxxxas' placing 'hom' from 2 for 4) = 4函数:position(substring in string)说明:Location of specified substring ⼦串在⼀字符串中的位置例⼦:position('om' in 'Thomas') = 3函数:substring(string [from int] [for int])说明:Extract substring 截取任意长度的⼦字符串例⼦:substring('Thomas' from 2 for 3) = hom函数:substring(string from pattern)说明:Extract substring matching POSIX regular expression. See Section 9.7 for more information on pattern matching. 利⽤正则表达式对⼀字符串进⾏任意长度的字串的截取例⼦:substring('Thomas' from '...$') = mas函数:substring(string from pattern for escape)说明:Extract substring matching SQL regular expression. See Section 9.7 for more information on pattern matching. 利于正则表达式对某类字符进⾏删除,以得到⼦字符串例⼦:trim(both 'x' from 'xTomxx') = Tom函数:trim([leading | trailing | both] [characters] from string)说明:Remove the longest string containing only the characters (a space by default) from the start/end/both ends of the string 去除尽可能长开始,结束或者两边的某类字符,默认为去除空⽩字符,当然可以⾃⼰指定,可同时指定多个要删除的字符串例⼦:trim(both 'x' from 'xTomxx') = Tom函数:upper(string)说明:Convert string to uppercase 将字符串转换为⼤写例⼦:upper('tom') = TOM函数:ascii(string)说明:ASCII code of the first character of the argument. For UTF8 returns the Unicode code point of the character. For other multibyte encodings. the argument must be a strictly ASCII character. 得到某⼀个字符的Assii值例⼦:ascii('x') = 120函数:btrim(string text [, characters text])说明:Remove the longest string consisting only of characters in characters (a space by default) from the start and end of string 去除字符串两边的所有指定的字符,可同时指定多个字符例⼦:btrim('xyxtrimyyx', 'xy') = trim函数:chr(int)说明:Character with the given code. For UTF8 the argument is treated as a Unicode code point. For other multibyte encodings the argument must designate a strictly ASCII character. The NULL (0) character is not allowed because text data types cannot store such bytes.得到某ACSII值对应的字符例⼦:chr(65) = A函数:convert(string bytea, src_encoding name, dest_encoding name)说明:Convert string to dest_encoding. The original encoding is specified by src_encoding. The string must be valid in this encoding. Conversions can be defined by CREATE CONVERSION. Also there are some predefined conversions. See Table 9-7 for available conversions. 转换字符串编码,指定源编码与⽬标编码例⼦:convert('text_in_utf8', 'UTF8', 'LATIN1') = text_in_utf8 represented in ISO 8859-1 encoding函数:convert_from(string bytea, src_encoding name)说明:Convert string to the database encoding. The original encoding is specified by src_encoding. The string must be valid in this encoding. 转换字符串编码,⾃⼰要指定源编码,⽬标编码默认为数据库指定编码,例⼦:convert_from('text_in_utf8', 'UTF8') = text_in_utf8 represented in the current database encoding函数:convert_to(string text, dest_encoding name)说明:Convert string to dest_encoding.转换字符串编码,源编码默认为数据库指定编码,⾃⼰要指定⽬标编码,例⼦:convert_to('some text', 'UTF8') = some text represented in the UTF8 encoding函数:decode(string text, type text)说明:Decode binary data from string previously encoded with encode. Parameter type is same as in encode. 对字符串按指定的类型进⾏解码例⼦:decode('MTIzAAE=', 'base64') = 123\000\001函数:encode(data bytea, type text)说明:Encode binary data to different representation. Supported types are: base64, hex, escape. Escape merely outputs null bytes as \000 and doubles backslashes. 与decode相反,对字符串按指定类型进⾏编码例⼦:encode(E'123\\000\\001', 'base64') = MTIzAAE=函数:initcap(string)说明:Convert the first letter of each word to uppercase and the rest to lowercase. Words are sequences of alphanumeric characters separated by non-alphanumeric characters. 将字符串所有的单词进⾏格式化,⾸字母⼤写,其它为⼩写例⼦:initcap('hi THOMAS') = Hi Thomas函数:length(string)说明:Number of characters in string 讲算字符串长度例⼦:length('jose') = 4函数:length(stringbytea, encoding name )说明:Number of characters in string in the given encoding. The string must be valid in this encoding. 计算字符串长度,指定字符串使⽤的编码例⼦:length('jose', 'UTF8') = 4函数:lpad(string text, length int [, fill text])说明:Fill up the string to length length by prepending the characters fill (a space by default). If the string is already longer than length then it is truncated (on the right). 对字符串左边进⾏某类字符⾃动填充,即不⾜某⼀长度,则在左边⾃动补上指定的字符串,直⾄达到指定长度,可同时指定多个⾃动填充的字符例⼦:lpad('hi', 5, 'xy') = xyxhi函数:ltrim(string text [, characters text])说明:Remove the longest string containing only characters from characters (a space by default) from the start of string 删除字符串左边某⼀些的字符,可以时指定多个要删除的字符例⼦:trim函数:md5(string)说明:Calculates the MD5 hash of string, returning the result in hexadecimal 将字符串进⾏md5编码例⼦:md5('abc') = 900150983cd24fb0 d6963f7d28e17f72函数:pg_client_encoding()说明:Current client encoding name 得到pg客户端编码例⼦:pg_client_encoding() = SQL_ASCII函数:quote_ident(string text)说明:Return the given string suitably quoted to be used as an identifier in an SQL statement string. Quotes are added only if necessary (i.e., if the string contains non-identifier characters or would be case-folded). Embedded quotes are properly doubled. 对某⼀字符串加上两引号例⼦:quote_ident('Foo bar') = "Foo bar"函数:quote_literal(string text)说明:Return the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. 对字符串⾥两边加上单引号,如果字符串⾥⾯出现sql编码的单个单引号,则会被表达成两个单引号例⼦:quote_literal('O\'Reilly') = 'O''Reilly'函数:quote_literal(value anyelement)说明:Coerce the given value to text and then quote it as a literal. Embedded single-quotes and backslashes are properly doubled. 将⼀数值转换为字符串,并为其两边加上单引号,如果数值中间出现了单引号,也会被表⽰成两个单引号例⼦:quote_literal(42.5) = '42.5'函数:regexp_matches(string text, pattern text [, flags text])说明:Return all captured substrings resulting from matching a POSIX regular expression against the string. See Section 9.7.3 for more information. 对字符串按正则表达式进⾏匹配,如果存在则会在结果数组中表⽰出来例⼦:regexp_matches('foobarbequebaz', '(bar)(beque)') = {bar,beque}函数:regexp_replace(string text, pattern text, replacement text [, flags text])说明:Replace substring(s) matching a POSIX regular expression. See Section 9.7.3 for more information. 利⽤正则表达式对字符串进⾏替换例⼦:regexp_replace('Thomas', '.[mN]a.', 'M') = ThM函数:regexp_split_to_array(string text, pattern text [, flags text ])说明:Split string using a POSIX regular expression as the delimiter. See Section 9.7.3 for more information. 利⽤正则表达式将字符串分割成数组例⼦:regexp_split_to_array('hello world', E'\\s+') = {hello,world}函数:regexp_split_to_table(string text, pattern text [, flags text])说明:Split string using a POSIX regular expression as the delimiter. See Section 9.7.3 for more information. 利⽤正则表达式将字符串分割成表格例⼦:regexp_split_to_table('hello world', E'\\s+') =helloworld(2 rows)函数:repeat(string text, number int)说明:Repeat string the specified number of times 重复字符串⼀指定次数例⼦:repeat('Pg', 4) = PgPgPgPg函数:replace(string text, from text, to text)说明:Replace all occurrences in string of substring from with substring to 将字符的某⼀⼦串替换成另⼀⼦串例⼦:('abcdefabcdef', 'cd', 'XX') = abXXefabXXef函数:rpad(string text, length int [, fill text])说明:Fill up the string to length length by appending the characters fill (a space by default). If the string is already longer than length then it is truncated. 对字符串进⾏填充,填充内容为指定的字符串例⼦:rpad('hi', 5, 'xy') = hixyx函数:rtrim(string text [, characters text])说明:Remove the longest string containing only characters from characters (a space by default) from the end of string去除字符串右边指定的字符例⼦:rtrim('trimxxxx', 'x') = trim函数:split_part(string text, delimiter text, field int)说明:Split string on delimiter and return the given field (counting from one) 对字符串按指定⼦串进⾏分割,并返回指定的数值位置的值例⼦:split_part(, , 2) = def函数:strpos(string, substring)说明:Location of specified substring (same as position(substring in string), but note the reversed argument order) 指定字符串在⽬标字符串的位置例⼦:strpos('high', 'ig') = 2函数:substr(string, from [, count])说明:Extract substring (same as substring(string from from for count)) 截取⼦串例⼦:substr('alphabet', 3, 2) = ph函数:to_ascii(string text [, encoding text])说明:Convert string to ASCII from another encoding (only supports conversion from LATIN1, LATIN2, LATIN9, and WIN1250 encodings)将字符串转换成ascii编码字符串例⼦:to_ascii('Karel') = Karel函数:to_hex(number int or bigint)说明:Convert number to its equivalent hexadecimal representation 对数值进⾏⼗六进制编码例⼦:to_hex(2147483647) = 7fffffff函数:translate(string text, from text, to text)说明:Any character in string that matches a character in the from set is replaced by the corresponding character in the to set 将字符串中某些匹配的字符替换成指定字符串,⽬标字符与源字符都可以同时指定多个例⼦:translate('12345', '14', 'ax') = a23x5。
字符串函数的用法

字符串函数的用法
字符串函数是编程中经常使用的一种函数,用来对字符串进行操作和处理。
不同编程语言的字符串函数可能会有所不同,但通常会包括以下常用函数:
1. strlen():用于获取字符串的长度,返回值为整数。
2. strcat():用于字符串拼接,将一个字符串连接到另一个字符串的末尾。
3. strcpy():用于字符串赋值,将一个字符串的值赋给另一个字符串。
4. strchr():用于查找字符串中的某个字符,返回指向该字符的指针。
5. strcmp():用于比较两个字符串的大小,返回值为整数,若两个字符串相等,则返回0。
6. strncmp():用于比较两个字符串的前n个字符的大小,返回值为整数,若两个字符串相等,则返回0。
7. strstr():用于在一个字符串中查找另一个字符串,返回指向该字符串的指针。
8. strtok():用于将字符串按照某个字符或字符串分割成多个子字符串,返回指向第一个子字符串的指针。
以上是常用的字符串函数,掌握它们的用法可以提高编程效率和代码质量。
同时,在使用字符串函数时需要注意字符串的长度和内存分配,避免出现内存溢出和程序崩溃的情况。
replace函数的使用方法

replace函数的使用方法在编程中,replace函数是一个非常常见的字符串函数,它可以用于替换字符串中的某个子串为另一个子串。
replace函数的使用方法如下:1. 语法:str.replace(old, new[, count])其中,str表示原字符串,old表示需要被替换的子串,new表示替换后的子串,count表示替换的次数(可选参数,默认为全部替换)。
2. 示例:str = 'hello world'str_replace = str.replace('world', 'python')print(str_replace) # 输出:hello python在上述示例中,我们将字符串中的'world'替换成了'python'。
3. 替换多个子串:str = 'hello world, hello python'str_replace = str.replace('hello', 'hi')print(str_replace) # 输出:hi world, hi python在上述示例中,我们将字符串中的所有'hello'替换成了'hi',由于没有指定替换次数,因此所有'hello'都被替换了。
4. 替换次数:str = 'hello world, hello python'str_replace = str.replace('hello', 'hi', 1)print(str_replace) # 输出:hi world, hello python在上述示例中,我们只替换了一次,因此只有第一个'hello'被替换成了'hi'。
总之,replace函数是一个非常实用的字符串函数,可以方便地替换字符串中的某个子串为另一个子串。
postgre pg_trgm用法

postgre pg_trgm用法"postgre pg_trgm用法"是指在PostgreSQL数据库中使用pg_trgm扩展,该扩展通过使用trigram索引来进行模糊字符串匹配和相似度比较。
在本文中,我们将逐步回答与pg_trgm使用相关的问题,并探讨如何在PostgreSQL中实现模糊搜索和相似度比较。
第一步:了解pg_trgm扩展的作用和原理pg_trgm是PostgreSQL中的一个扩展,它通过使用trigram(三字母组)索引来实现字符串匹配和相似度比较。
trigram是由字符串中的三个字母组成的,这种索引方式可以在进行字符比较时忽略无关字符的顺序和位置,从而更好地处理拼写错误和模糊搜索。
第二步:安装和启用pg_trgm扩展要使用pg_trgm扩展,首先需要确保其已经安装并在PostgreSQL中启用。
在安装PostgreSQL时,可以选择包含pg_trgm扩展,若未选择安装,也可以通过以下方法手动安装:1. 登录到PostgreSQL数据库服务器。
2. 运行以下命令安装pg_trgm扩展:CREATE EXTENSION pg_trgm;第三步:创建包含pg_trgm索引的表在使用pg_trgm进行模糊搜索和相似度比较之前,需要在表中创建适当的索引。
下面是一个示例表的创建和索引添加的SQL语句:CREATE TABLE customers (id SERIAL PRIMARY KEY,name VARCHAR(100));CREATE INDEX idx_customers_name_trgm ON customers USING gist (name gist_trgm_ops);在上述示例中,我们创建了一个名为"customers"的表,其中包含一个"id"列和一个"name"列。
然后,我们对"name"列添加了一个trigram索引。
postgrep 字符串函数

postgrep 字符串函数postgrep 是一个强大的字符串函数库,用于在 PostgreSQL 数据库中进行高效的字符串操作。
它提供了各种函数,用于处理字符串的搜索、替换、截断、连接、转换等操作。
下面是一些常用的 postgrep 字符串函数及其用法:1. `substring(str text, from integer [, to integer])` 函数用于提取字符串的子串。
参数 `str` 是要处理的字符串,`from` 是起始位置,`to` 是可选的结束位置。
下面的示例演示了如何使用该函数:```sqlSELECT substring('Hello World!', 7); -- 输出 'World!' SELECT substring('Hello World!', 7, 9); -- 输出 'Wo'```2. `position(substring text IN str text)` 函数用于查找子串在字符串中的位置。
下面的示例演示了如何使用该函数:```sqlSELECT position('World' IN 'Hello World!'); -- 输出 7```3. `replace(str text, from text, to text)` 函数用于替换字符串中的子串。
参数 `str` 是要处理的字符串,`from` 是需要替换的子串,`to` 是替换后的新子串。
下面的示例演示了如何使用该函数:```sqlSELECT replace('Hello World!', 'World', 'PostgreSQL'); -- 输出'Hello PostgreSQL!'```4. `trim([both] characters FROM str text)` 函数用于去除字符串两侧的指定字符。
pgsql encode用法

pgsql encode 用法1. 介绍在 PostgreSQL 数据库中,encode 函数是用于将字节序列转换成文本的函数。
它可以将数据从字节表示形式编码到文本表示形式。
该函数的语法如下:```sqlencode(input bytea, format text) RETURNS text```其中,input 是一个字节序列;format 是指定编码的格式,可以是base64、escape、hex 中的任意一个。
encode 函数的返回值为文本类型。
2. base64 编码base64 编码是一种常用的编码方式,它将二进制数据转换成文本字符串形式。
使用 base64 编码可以方便地将二进制数据传输或存储,因为它只包含 A-Z、a-z、0-9、+、/ 这几个字符,不会包含特殊字符。
示例:```sqlSELECT encode(E'\x1234'::bytea, 'base64');```结果为:```sqlencode-----------------ESM0(1 row)```3. escape 编码escape 编码是一种将二进制数据转换成文本字符串形式的编码方式。
它使用反斜杠和八进制数表示字节值。
escape 编码的结果可能比较臃肿,因为它会在每个字节前添加反斜杠。
示例:```sqlSELECT encode(E'\x1234'::bytea, 'escape');```结果为:```sqlencode---------\264(1 row)```4. hex 编码hex 编码是一种将二进制数据转换成十六进制字符串形式的编码方式。
它使用 0-9、a-f 这几个字符表示十六进制数。
示例:```sqlSELECT encode(E'\x1234'::bytea, 'hex');```结果为:```sqlencode---------1234(1 row)```5. 总结encode 函数提供了将字节序列以不同编码方式表示的能力,通过选择不同的编码格式,可以根据实际需求灵活地进行转换。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
C语言中字符串库函数的使用
1.连续输入两个串时使用gets()函数比较好,两个串以回车为分隔。
#include"string.h"
main()
{char str1[20],str2[20];
printf("input 2 strings:\n");
gets(str1);
gets(str2);
printf("str1:%s\n",str1);
printf("str2:%s\n",str2);
}
2. 连续输入两个串时如果使用scanf()函数,空格、Tab、回车均为分隔。
#include"string.h"
main()
{char str1[20],str2[20];
printf("input 2 strings:\n");
scanf("%s",str1);
scanf("%s",str2);
printf("str1:%s\n",str1);
printf("str2:%s\n",str2);
}
3.puts()字符串输出函数
#include"stdio.h"
#include"string.h"
main()
{
char str1[]={"a dog is a dog!abcdefg"};
char str2[20]="China V on Korea";
char str3[]="You\nMe";
char str4[]={"I said:\"Are you ok?\""};
puts(str1);
puts(str2);
puts(str3);
puts(str4);
}
4.scanf(“%s”,str)输入串,若输入串数多于1个则以空格、Tab、回车结束。
若输入串数为1个,以回车结束。
#include"string.h"
main() {char str1[20];
printf("input a string:\n");
scanf("%s",str1);
printf("%s\n",str1);
}
5.gets(str)输入串时以回车结束。
#include"string.h"
main()
{char str[20];
printf("input a string:\n");
gets(str);
printf("%s\n",str);/* puts(str) ;*/
}
6.分析此程序的输出结果
#include"string.h"
main()
{
char str2[]={"abc 123\0def"};
printf("str2:%s\n",str2);
puts(str2);
}
7.串拷贝函数strcpy(str1,str2)
#include"stdio.h"
#include"string.h"
main()
{
char str1[30]={"Hello!This is ABC."}; char str2[30]={"Who are you?"}; strcpy(str1,str2);
puts(str1);
puts(str2);
}
8.串连接函数strcat(str1,str2)
#include"string.h"
main()
{char str1[30]={"I want to"};
char str2[20]={" lose weight!"}; strcat(str1,str2);
puts(str1);
puts(str2);
}
9.3个串连接
#include"string.h"
main()
{char str1[30]={"I want to"};
char str2[]={" lose weight!"},str3[]="what about you?"; strcat(strcat(str1,str2),str3);
puts(str1);
}
10.串比较函数strcmp(str1,str2)
#include"stdio.h"
#include"string.h"
main()
{int i;
char str1[]={"Hello!This is ABC."};
char str2[]={"Who are you?"};
if(strcmp(str1,str2)>0)
printf("\nstr1 is bigger than str2!\n");
else if(strcmp(str1,str2)==0)
printf("\nstr1 is equal to str2!\n");
else
printf("\nstr1 is smaller than str2!\n");
}
11.注意串拷贝后str1的变化
#include"stdio.h"
#include"string.h"
main()
{int i;
char str1[30]={"Hello!This is ABC."};
char str2[30]={"Who are you?"};
strcpy(str1,str2);
puts(str1);
puts(str2);
for(i=0;i<30;i++)putchar(str1[i]);
}
#include"stdio.h"
#include"string.h"
main()
{int i;
char str1[30]={"Hello!This is ABC."};
char str2[30]={"Who are you?"};
printf("\nthe length of str1 is:%d\n",strlen(str1));
printf("the length of str2 is:%d\n",strlen(str2));
printf("th length of \"abc\" is:%d\n",strlen("abc"));
}
12.将串中大写字母变小写:strlwr(str)
将串中小写字母变大写:strupr(str)
#include"stdio.h"
#include"string.h"
main()
{int i;
char str1[30]={"ABC123def"};
char str2[30]={"abc456DEF"};
printf("\nstr1 is:%s\n",strlwr(str1));
printf("str2 is:%s\n",strupr(str2));
}
练习题:
试不使用库函数自己编制串拷贝,串连接,测试串长,串比较,串中大写字母变小写等程序。