C Dynamic variables generated small example!

xiaoxiao2021-03-06  38

Since I entered the university, I learned C language, just played while learning, I thought about it, I couldn't think of it. Sometimes I want to learn it yourself, sometimes it is very poor! You must use it through the pointer. Malloc build space, otherwise it is difficult to expect. One example below (not very perfect): # include #include #define n 10 // Define the maximum space size int main () {

Char * s [5]; // Pointer array, used to store an address INT i; / / counter

For (i = 0; i <5; i ) // allocation space, obtain input scanf ("% s", s [i] = (char *) malloc (n * sizeof (char)));

For (i = 0; i <5; i ) // Print Printf ("% S / N", S [I]);

For (i = 0; i <5; i ) // Release space free (s [i]);

Return 0;}

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

New Post(0)