Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,128 questions

40,777 answers

573 users

How to remove last two characters from a string in C

Learn & Practice SQL


69 views
asked Sep 27, 2021 by avibootz
edited Sep 27, 2021 by avibootz

1 Answer

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

int main(void) {
    char str[] = "C Programming";    
    
    puts(str);
    
    str[strlen(str) - 2] = '\0';
    
    puts(str);
    
    return 0;
}




/*
run:

C Programming
C Programmi

*/

 





answered Sep 27, 2021 by avibootz

Related questions

1 answer 35 views
1 answer 68 views
1 answer 79 views
1 answer 29 views
1 answer 57 views
...