Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cctype>
- #include <cstring>
- #include <cstdlib>
- #include <string>
- using namespace std;
- int main()
- {
- char string[] = "-4x^0 + x^1 + 4x^3 - 3x^4";
- int length = strlen(string);
- char copy[length];
- strcpy(copy, string);
- char *p = strtok(string, " +-");
- char *search;
- int counter = 0;
- while (p)
- {
- search = strstr(p, "x^");
- cout << "Token: " << p << endl;
- cout << "Search " << search << endl;
- p = strtok(NULL, " +-");
- counter++;
- }
- cout << copy << endl;
- cout << "counter " << counter << endl;
- int *coefficient;
- coefficient = new int[counter];
- p = strtok(copy, " +-");
- int a;
- while (p)
- {
- if (isdigit(p[0]))
- {
- cout << p[0] << " is a digit" << endl;
- char c = p[0];
- int b = c - 0;
- coefficient[a] = ;
- }
- p = strtok(NULL, " +-");
- a++;
- }
- for (int i = 0; i < counter; i++)
- cout << coefficient[i] << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment