Quantcast
Viewing all articles
Browse latest Browse all 25

String copier project help

I am trying to write the code for the “String Copier” project (link to the project

)
that comes with the C lesson on pointers.
I don’t understand what’s wrong with my code.
It outputs a bunch of error messages which I don’t understand. Could you help?

#include<stdio.h>
#include<string.h>
 
void copy(char* dst, char* src){
  while(*src != '\0'){
    strcpy(*dst,*src);
    src++;
    dst++;
  }
  *dst= '\0';
}
int main(){
  char srcString[] = "We promptly judged antique ivory buckles for the next prize!";
  int len= strlen(srcString) + 1;
  
  char dstString[len]{
    strcpy(*dstString,*srcString);
    printf("%s",dstString);

  }
}

4 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 25

Trending Articles