I am working on a project that converts a char array to a float, however I keep getting a debug assertion failure. I know it is in the if statement (code below), I just can't figure out why it's causing this.
_______________________________________________
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctype.h>
#include <math.h>
using namespace std;
Thanks for that note, I'm new at this so syntax errors are no rare thing. I added '\0'to the end of tempstr( using tempstr[strlen(tempstr)]= '\0;). Still no change. The error goes away if I comment out the for loop though.
on a side note, it's interesting that you need to do 2 backslashes to post \0
strlen requires a null-tesminated string as well.
Since you have a loop ( and a counter! ) you have to keep track the actual length of the C-string yourself.
If you don't bother, you can use std::string instead of char arrays