[Solved] C – Trouble calling a function


Here is a main() that calls base64_encode():

int main(void) {
  char data[] = "test";
  char *encoded_data;
  size_t len;

  encoded_data = base64_encode(data, strlen(data), &len);
  printf("%s (%zu) => %s (%zu)", data, strlen(data), encoded_data, len);
}

Explanation

  • char data[] contains your string to encode. You’ll need to pass it as an argument to base64_encode().
  • char *encoded_data is a pointer that you’ll use to store the return value of base64_encode(). You will use this variable to access the decoded string, since base64_encode() returns a pointer to an allocated space where the decoded string is stored.
  • size_t len is a variable that will be used to store the size of the decoded string. You’ll give a pointer to this variable as argument to base64_encode().
  • strlen(data), the second argument to base64_encode(), is the length of char data[].

0

solved C – Trouble calling a function