+ 2

How to remove first character from a string

input-skillrack output-killrack In printf what should I fill so that all characters except first character is printed #include <stdio.h> int main() { char s[100]; scanf("%s",s); printf(" ") }

15th Mar 2021, 11:18 AM
S.Brindha
S.Brindha  - avatar
4 odpowiedzi
+ 8
printf("%s\n", s + 1); s + 1 means start printing from the second character (having index -> 1). This isn't really removing first character though, just skipping the first character while printing.
15th Mar 2021, 11:22 AM
Ipang
+ 4
You can print string from s[1] to last character s[s.length()-1] by a loop.... if you want to just by printf then use s+1 : printf("%s",s+1);
15th Mar 2021, 11:21 AM
Jayakrishna 🇮🇳
+ 3
Done thank you😊
15th Mar 2021, 11:25 AM
S.Brindha
S.Brindha  - avatar
0
For removal you could use: memmove(s, s + 1, strlen(s));
15th Mar 2021, 11:57 AM
Mike A
Mike A - avatar