
Hamid H. answered 04/02/20
Tutor
5.0
(76)
PhD Candidate in Computer Sci. with 10+ Years of Experience in Coding
use fstream, read the whole line into a buffer and then do something like this:
count =0
for (int I =0 ;I<strlen(buff); I++)
if (buff[I]==' ')
count++;