fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int main(void) {
  6.  
  7. char putEndpoint[] = "PUT /api/v1/products/";
  8. char http[] = " HTTP/1.1";
  9. char *putRequestEndpoint;
  10.  
  11. putRequestEndpoint=malloc(strlen(putEndpoint)+strlen(http)+1); //allocating memory
  12.  
  13. sprintf(putRequestEndpoint,"%s%s",putEndpoint,http);
  14. printf("%s\n",putRequestEndpoint);
  15. printf("%s",putEndpoint);
  16. free(putRequestEndpoint); //freeing memory
  17. return 0;
  18. }
Success #stdin #stdout 0s 2244KB
stdin
Standard input is empty
stdout
PUT /api/v1/products/ HTTP/1.1
PUT /api/v1/products/