Added cbd_rand. Generates x random numbers in y columns. Interactive program.
[C-Programming-Examples.git] / ex_5-3.c
blob0f4586da259d59d9ed19414760eb21ebf3787ae8
1 #include <stdio.h>
2 #include <string.h>
4 /* print contents of array */
5 void print_array(char s[])
7 int i;
8 for(i = 0; i < strlen(s); i++)
9 printf("%c", s[i]);
10 printf("\n");
13 /* previous version of strcat */
14 void strcat_old(char s[], char t[])
16 int i, j;
17 i = j = 0;
18 while(s[i] != '\0')
19 i++;
20 while((s[i++] = t[j++]) != '\0')
24 /* copy string of chars from t into s */
25 void strcopy(char *s, char *t)
27 while(*s++ = *t++);
30 /* pointer version of strcat - add string t to end of string s */
31 void strcatptr(char *s, char *t)
33 while(*s) { ++s; } // find pointer val for end of string s
34 strcopy(s,t);
37 int main()
39 char buffer[128];
40 char s[] = { "this is a string of chars " };
42 strcatptr(buffer,s);
43 strcatptr(buffer,s);
45 print_array(buffer);
47 printf("\n");
49 return 1;