Helloo... been staring at the same screen for too long and am hoping I can get a tip or two off you cboarders!
I have attempted to re-code the BZERO function. The function appears to do what I want it to do. I am having trouble printing out the result in my main for testing purposes. My main output keeps showing nothing..
Regarding pointers, is it possible to go back with a pointer after having gone forward? In my example, my string is "abcdcdee". Once I have moved the pointer to "ee", can I move it back to retrieve the full string again, to then send it back in to the main?
Function:
Code:
#include <stdlib.h>
void ft_bzero(void *s, size_t n)
{
char *sentence;
sentence = (char*)s;
printf("n is: %u\nsentence is: %c\n\n\n", n, *sentence);
while(n > 0)
{
printf("n is: %u\nBEFORE: %c\n", n,*sentence);
*sentence = '\0';
printf("AFTER: %c\n\n", *sentence);
sentence++;
n--;
}
//sentence = sentence - n????;
printf("The remainder:\n%s\n\n", sentence);
return(0);
}
MAIN:
Code:
#include <stdio.h>#include <string.h>
int main () {
char str[] = "abcdcdee";
int c = 6;
ft_bzero(str, c);
printf("String after first |%d| bytes changes to 0 is - |%s|\n", c, str);
return(0);
}