Math with chars

Whenever I try to print this I get: a n, a dash mark and two tildas stacked on top of each other

it should print the number of letters it takes to get to a space

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    
    
char english[] = "This is a test";
char length = strlen(english);//if I change this to a char same output :(


int temp2;

char curnum;
char *temp = strchr(english,' ');
     while (temp != NULL){
          temp2 = strlen (temp);
          temp++;
          curnum = temp2 - length;
          cout << curnum << endl;
          temp = strchr(temp,' ');
     }
    
    
    system("PAUSE"); // not using in final goal ...just for now
    return EXIT_SUCCESS;
}
Convert to int or any type other than char right before outputting (<<(int)curnum).
Topic archived. No new replies allowed.