Hey fellers. I'm brand spanking new to the forums and I wanted to introduce myself with my first post. So honestly, I'm working on my homework, and the problem is I'm looking to input a fraction like so "5 2/3". Now I figured I would use a pointer to a char, from there I would tokenize this string for the space and the forward slash. The current problem is that I use scanf, with that pointer yet my program crashes...I'm calling scanf like so:
char stockTicker[6+1];
char *pFraction = NULL;
float pricePerShare,
sharesPurchased,
stockValue;
int whole,
num,
dem, i = 0;
char slash;
printf( " Enter the stocker symbol: " );
scanf( "%s", &stockTicker );
printf( "\n Enter the price per share of %s: ", stockTicker );
scanf( "%s", &pFraction ); //Doesn't crash here
printf( "%s", *pFraction ); //Actually its crashing here. ???
I would prefer it if the solution doesn't have any function calls to another library. Oh and I just read the homework topic, I'm not intending for you all to do my work...the thing is...I have the solution but its in c++, all it required was using cin....*sigh*