How to reset a char[] in C

1 Answer

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

int main() {
    
    char str[] = "abcd";
    
    printf("str = %s\n", str);

    memset(str, 0, sizeof(str));
    
    printf("str = %s\n", str);
}



/*
run:

str = abcd
str = 

*/

 



answered Jun 1, 2024 by avibootz

Related questions

1 answer 235 views
235 views asked Apr 13, 2024 by avibootz
1 answer 258 views
1 answer 222 views
1 answer 243 views
243 views asked Dec 27, 2020 by avibootz
...