An autocommand command is executed when one event occurs. You want a command to be executed after a sequence of events has occurred. One way to do that is like this:
autocmd FileType c,cpp,python
\ autocmd BufWritePre <buffer> call StripTrailingWhiteSpaces()
The <buffer>
pattern causes the autocommand to be be triggered when the current buffer is written. See
:help autocmd-buflocal
Update
The solution above is pretty simple and has some flaws that were discussed in the Comments. Here is a more complete solution that addresses some of those flaws. It puts the autocommands in a group and deletes the BufWritePre autocommand, if one exists, before creating a new one. It still creates one autocommand per buffer, but only one.
augroup TrailSpace
autocmd FileType c,cpp,python
\ autocmd! TrailSpace BufWritePost <buffer> call SkipTrailingWhiteSpaces()
augroup END
Another solution, similar to the answer posted by lcd047, now deleted, is to recognize that when the FileType event occurs, the 'filetype' option is set. Then you can condition the response to the BufWritePost event on the value of 'filetype', as in the following example. It has the advantage over the other solutions that only one autocommand is created.
autocmd BufWritePre * if count(['c','cpp','python'],&filetype)
\ | call SkipTrailingWhiteSpaces()
\ | endif