How to print the print first 5 characters from a string in C

1 Answer

0 votes
#include <stdio.h>
  
int main()
{
    char str[] = "c java c++ python c# php";
    
    printf("%.5s\n", str);
  
    return 0;
}
  
  
  
  
/*
run:
      
c jav
      
*/

 



answered Jun 3, 2023 by avibootz

Related questions

2 answers 156 views
2 answers 134 views
1 answer 116 views
1 answer 163 views
1 answer 157 views
1 answer 113 views
1 answer 83 views
...