w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
how to reverse the integers between two strings with changing lower to upper & upper to case alphabets in c

The problem with "after executing it will only prints first string only and the rest of output vanishes" is:


The scanf() '%s' format string tells scanf to read in a string, but only up to the first space. Hence, if you enter:

 "Hello 12345 WoRlD"

The scanf("%s", s) will copy only "Hello" into 's'.

To fix this, change:


To this:

fgets(s, sizeof(s), stdin);

However, fgets() may leave a unwanted ' ' at the end of the string. The unwanted ' ' can be eliminated by inserting the following code after the fgets():

   *q = '';

Then the output will be:

"hELLO 12345 wOrLd"


See my version 'casechange()', which will also reverse the number.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.