From

xiaoxiao2021-03-06  134

// Test.cpp: Defines the entry point for the console application.//

#include "stdafx.h"

#include #include #include #include #include #include

Typedef struct list {void * data; struct list * next;

List;

File * stream; char ** f1 (); int F2 (); int index; int F3 (); char * substring (const amount, const unsigned int end); int Split (Char string [], const char * chars, char * substr []); int getList (list * list, int LEN, char * initdata); char * getArray ();

INT main (void) {// f2 (); // f3 (); / * char * s = "I this a string";

Stream = fopen ("C: //c1.text", "W"); FPRINTF (stream, "% s", s); fclose (stream); Printf ("% s / n", s); * / / ************************************************ // Unsigned Short Str [50]; char STR [100]; char s [] = "xmlns"; stream = fopen ("c: //c1.text", "r"); while (! Feof (stream)) {FGETS (STR, 100, stream); // Read PrintF ("% s", str) progressively; Printf (".% D", strs); char * p1 = strstr (STR, S); if (p1! = Null) Printf "% s", p1);} fclose (stream); ******************************************* ** char string [] = "Akjf, Akdjfadfj, DJFK"; char * SEPS = ", A"; char * s [10]; int N = Split (STRING, SEPS, S); Printf ("s =% s / N ", S [2]); Printf (" n =% D ", N); return 1; *********************** ******* Char * text; int x = 5; text = (char *) Malloc ((x 1) * sizeof (char)); for (int i = 0; i <5; i ) Text [i] = 'a'; text [i] = 0; Printf ("% s", text); Printf ("=% D / N", strlen (text)); Printf ("% D", SIZEOF Int);

*************************** Char * str = getArray (); Printf ("% s.", Str); *** *************************** / List * L, * p; getList (L, 15, "123456"); p = L; While (p! = null) {Printf ("% s / n", (char *) P-> data);

GetChar (); return 0;} char * getArray () {// char Array [20] = "Who is you?"; char * array = (char *) Malloc (20); strcpy (array, "hei") ; // char * array = "hehehehe"; return array;}

INT getList (List * List, int Len, char * initdata) {list first, * plist; char * DD = (char *) malloc (80); if (dd == null) {Printf ("Malloc Error!") Return 0;} strcpy (dd, initdata); first.data = (void *) Dd; first.next = null; list = & first;

PLIST = & fourst; for (int i = 1; i next = & item; plist = & item;}

Return Len;}

// Divide the string int split (char string [], const char * seps, char * substr []) {int = 0; SUBSTR [I] = STRTOK (STRING, SEPS); // Printf ("% S / N", SUBSTR [I]); while (SubStr [i]! = null) {cout << Substr [i] << endl; i ; substr [i] = strtok (null, seps); } RETURN I;

// Mode match: strstrf2 () {char str [] = "tazy"; char string [] = "The quick brown dog jumps over the lazy fox"; char fmt1 [] = "1 2 3 4 5"; char FMT2 ""; "; Chinese Journal of 1984590 "

Char * pdest; int result; result = index (string, str); Printf ("Result =% D", Result); pdest = strstr (string, str); Printf ("% s", pdest); Return 0; } // Custom Subsidence function int index (char * value, const char * substring) {char * pindex = strstr (value, substring); int i = pindex-value 1; if (pindex! = Null) RETURN I-1; Else Return -1;} f3 () {char * s = substring (2, 19); Printf ("% s / n", s); return 0;} // Customized Subtrive Function Char * Substring (const amount, const unsigned {char * value = "The quick brown dog jumps over the lazy fox"; intlene = end-start; if (end> strlen) length = Strlen (value) -start; char * str = (char *) Malloc (length 1); Strncpy (Str, Value Start, Length); StrnSet (Str Length, '/ 0', 1); // Printf ( "str.length =% D", end-start 1); return str;} / ***************************** ************ /

转载请注明原文地址:https://www.9cbs.com/read-99879.html

New Post(0)