The process I would like to attempt is:
1. Start count out at zero.
2. Read in lines of original.c one by one.
3. For each line:
4. Remove all the white space (tabs and spaces) from the front of the line.
5. If the first non-white character of the line is ‘}’ decrease count by one.
6. Insert at the front of each line count*2 number of space characters.
7. If the first non-white character of the line is ‘{’ increase count by one.
The code I wrote is a not a good attempt so I would appreciate any help in fixing this code
Expand|Select|Wrap|Line Numbers
- int main(char string[])
- {
- const char sp = '.';
- const char cr = '*';
- const char tab = '$';
- const char rb = '{';
- const char br = '}';
- const char space = ' ';
- char ch;
- int in = 0;
- int count = 0;
- int inSpace = 0;
- while( (ch = string[count]) == sp|| ch == cr|| ch == tab || ch == space )
- count++;
- while ( ch = string[count++] )
- {
- if (ch == br)
- {
- count--;
- }
- }
- while ( ch = string[count++] )
- {
- if ( ch = rb)
- {
- count++;
- }
- }
- }