here is my coding so far:
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
main()
{
ifstream infile;
ofstream outfile;
char ch;
int counter=0;
infile.open("before.txt", ios:ut);
while(infile.get(ch))
{
cout << ch;
if(ch == ' ')
{
counter ++;
}
}
cout <<endl<<counter<<endl;
return 0;
}
This counts the spaces in a text file, what I need to do is count the spaces just b4 the lines.
this is the txt file:
// A short example file
float singleTax (float income)
{
if (income <= 20350.0)
return (income 8 0.15);
else
if (income <= 49300.0)
return (3052.50 + (0.28 * (income - 20350.0)));
else
return (11158.50 + (0.31 * (income - 4900.0)));
}
please help me if you can
Thanks in advance