repl.it
@t3m2/

pg 218, s ex 2.

C

No description

fork
loading
Files
  • main.c
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>

char * memset1(char v[], char ch, int n);

char * memset1(char v[], char ch, int n)
{
  for(int i=0;i<n;i++)
    v[i] = ch;
  return v;
}


int main(void)
{
  const int n_of_elements = 10;
  
  char v[n_of_elements] = {'a','b','c','d','e','f','g','h','i','j'};

  int i;
  
  for(i=0; i<n_of_elements; i++)
  {
    printf("%c",v[i]);
  }

  putchar('\n');

  memset1(v, 'g', 4);

  for(i=0; i<n_of_elements; i++)
  {
    printf("%c", v[i]);
  }

  putchar('\n');

  for(i=0; i<n_of_elements; i++)
  {
    printf("%c", memset1(v, 'e', 3)[i]);
  }

  return 0;
}
Fetching token
?