So- my program does not stop on condition (str2[o] != \'+\') So if anyone knows why and how to fix it it will help me ( :.
this is My code -
#include <
At the moment +
will be copied to str2, o index will point to the next char, which most probably won't be +
, so you condition will never be true. This could be possible solution :
do
{
str2[o] = str3[w];
o++;
w++;
}
while(str2[o-1] != '+' );
while(str2[o] != '+')
{
str2[o] = str3[w];
o++;
w++;
}
Assume o == x. You're assigning value to str2[x]. In while, you are seeing if str2[x+1] == '+', but str2[x+1] is empty.
you need to check the last updated value in str2, but you are checking the next value which is not initialized with a character so the loop will keep on repeating itself. you can do this:
while(str2[o-1] != '+'){
str2[o] = str3[w];
o++;
w++;
}
This line
while(str2[o] != '+')
provokes undefined behaviour as str2
's elements had not been properly initialised before being read.
To fix this do
char str2[9] = "":