Character array Reverse
#include <stdio.h>
void Daoxu (char str[]) {
int i;
char temp;
for (i = 0; i < strlen (str)/2; i + +) {
temp = str[i];
Str[i] = Str[strlen (str)-i-1];
Str[strlen (str)-i-1] = temp;
}
Word Count
int WordCount (char str[]) {
int i;
int count = 0;
int word = 0;
for (i = 0; str[i]!= '; i + +
} {if (str[i] = = ')
{
word = 0;
} else if (Word = = 0)
{
word = 1;
Count + +;
}
}
return count;
}
Character uppercase to lowercase
void Mylwr (char str[]) {
int i;
for (i = 0; Str[i]!= ' and i + +]
{
if (Str[i] >= ' A ' && str[i] <= ' Z ')
{
Str[i] + = ' a '- ' A ';
}
}
Character Lowercase to uppercase
void Myupr (char str[]) {
int i;
for (i = 0; Str[i]!= ' and i + +
} {
if (Str[i] >= ' A ' && str[i] <= ' z ')
{
Str[i] = ' A '-' A ';}}
Character array evaluates string length
int Mylen (char str[]) {
int len;
for (len = 0; Str[len]!= ' "; len + +);
return len;
}
string concatenation
void Mycat (char Str1[],char str2[]) {
int i,j;
for (i = 0; str1[i]!= '; i++
'; for (j = 0; Str2[j]!= '; j + +]
{
str1[i + j] = Str2[j];
}
Str1[i + j] = ' I ';
}
Specify length string
void Myncat (char str1[],char str2[], int len) {
int i,j;
for (i = 0; str1[i]!= '; i++
'; for (j = 0; J < Len; j +)
{
str1[i + j] = Str2[j];
}
Str1[i + j] = ' I ';
}
Character array copy
void mycpy (char Dst[],char src[]) {
int i = 0;
Do
{
dst[i] = Src[i], while
(src[i++]!= ' ");
}
Character array Specify length copy
void myncpy (char dst[],char src[], int len) {
int i;
for (i = 0; i < len; i++)
{
Dst[i] = Src[i];
}
Dst[i] = ' I ';
}
Find the longest word in the sentence
void Longest (char Dst[],char src[]) {
int i = 0,j;
int count =0;
int max =-1;
Do
{
if (src[i] = = ' | | src[i] = = ' = '
{
if (Count > Max)
{
max = count;
for (j = 0; J < Count; J +)
{
Dst[j] = Src[i-count + j];
}
DST[J] = ' I ';
}
Count = 0;
} else{
count++
}
} while (src[i++]!= ' a ');
}
To extract an orthopedic number from a string
#include <stdio.h>
int getint (char str[], int a[]) {//Extract the number from the string and place it in the array
int i = 0;
int w = 0;
int c = 0;
Int J, K;
Do
{
if (Str[i] > ' 0 ' && str[i] <= ' 9 ')
{
w++;
} else if (W)
{
j = 0;
for (k = w; k > 0; k--)
{
J *=;
J + + Str[i-k]-' 0 ';
}
w = 0;
A[c] = j;
C + +;
}
} while (str[i++] "!=");
return c;
}
void Main () {
char str[100];
int a[100];
int I, J;
Gets (str);
i = Getint (str,a);
for (j = 0; J < i; j +)
{
printf ("%d", a[j]);
}
Shaping, character-array conversions
#include <stdio.h>
#include <stdlib.h>
int sumof1 (int x)//Find the number of 1 after converting to binary
{
int countx = 0;
while (x)
{
countx + +;
x &= x-1; Each with a x-1, you can erase the last 1} return
countx;
void Main () {
char c[10];
int i = 999;
Itoa (i, C, 10);//Convert to a character array
puts (c) in 10;
Itoa (i, C, 16);//Convert to an array of characters in 16
; printf ("0x%s\n", c);
Itoa (i, C, 8);//Convert to an array of characters in 8
; printf ("0%s\n", c);
Itoa (i, C, 2);//Convert to a character array
puts (c) in 2;
i = Atoi (c);//Then turn the string into an orthopedic
printf ("%d\n", I);
printf ("%d\n", Sumof1 (i));//1 number in 2