C - Print each character of string until reach '\0' Code Example

The code for Print each character of string until reach '\0'

#include <stdio.h>

int main(void) {
  int i = 0;
  char *str = "IncludeHelp!\n";

  // Print each character until reach '\0'
 while (str[i] != '\0')
 printf("%c", str[i++]);

 return 0;
}

/*
Output:
IncludeHelp!
*/
Code by IncludeHelp, on August 12, 2022 08:33

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.