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 160 views
2 answers 136 views
1 answer 119 views
1 answer 169 views
1 answer 160 views
1 answer 119 views
1 answer 87 views
...