Quantcast
Channel: C - Codecademy Forums
Viewing all articles
Browse latest Browse all 25

Please Help me. Nothing being Printed probably Pointer mistake

$
0
0

So I was programming C in one of the lessons and nothing is being printed to the console. Please help. Here is my code. No errors are coming up!

#include<stdio.h>
#include<string.h>

void copy(char* dst, char* src){
while(src != “\0”)
{
*dst = *src;
src++;
dst++;
}
*dst = 0;
}

int main(){
char srcString = “We promptly judged antique ivory buckles for the next prize!”;
int l = strlen(srcString);
char dstString[l];
char *srcPtr = &srcString[0];
char *dstPtr = &dstString[0];
copy(dstPtr, srcPtr);
dstPtr = &dstString[0];
for(int i = 0; i < strlen(dstString); i++)
{
printf(“%c”, *dstPtr);
dstPtr++;
}
}

7 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 25

Trending Articles