don't change your string pointer.
this: string=string+1;
you loose the beginning of your string.
Try this instead: string[i] = getchar();
(you would need an i variable that gets incremented...
Type: Posts; User: noobiept
don't change your string pointer.
this: string=string+1;
you loose the beginning of your string.
Try this instead: string[i] = getchar();
(you would need an i variable that gets incremented...
I can't see a problem there, but you've got alot of if else statements there. When one of them evaluates to true, the rest is bypassed, so maybe that's where the problem occurs.
For example if...
can you post more of your code?
That's because the first if is going to evaluate to true, and jumps the else if.
You could try having the if (a == 0 && b == 0) first, and then the if (a== 0), changing the order.
or you could, ...
you aren't changing the variable index, so your loop is stuck.
count is doing nothing as well.
Try converting the number to string (you can use sprintf for that).
Then you can travel through that string (with a pointer) and compare each character separately, and then add to the counter.
thought of another way, you could make a loop on main, but you would loose the first value(since you would be changing the same variable)
I wonder what is the idea of that sort of rule, but anyway, why not just copy past the code and change the variable names?
Kinda stupid, but works :p
you can change the order that you print to the screen.
For example, printf("...", b, c, d, e, a);
Kinda of a trick, since you're not really changing anything.
If you want to use that function...
why can't you pass parameters?
you're calling your function with char variables, but then you use char pointers in the function, that's what the message is saying.
Either way, what do you mean by shifting the value?
For me, the less you mess around with banks the cheaper it is. They just want you to signup to tons of "services", so that they can take their cut out of it.
you should send the size of the strings as a parameter.
also in the first loop, is probably not doing what you think, you're comparing a single character, *old_s(and it is always the same),...
you have consecutive ifs, so each one is going to be evaluated every time.
You could try instead something like this:
if (...)
{}
else if (...)
{}
else if (...)
{}
I think you didn't understand what I was saying, but either way I search a bit and read about it.
thanks for the answers!
I was referring to the order of evaluation, and not the operator precedence (or maybe I'm confusing myself?)
Ok, I was assuming that operator precedence would determine the order of evaluation. Didn't know it was something different.
Guess I learned something today :)
Just a last question, how do we...
I still don't get it, because the || is been evaluated first. Doesn't having higher precedence means that it is evaluated first? This way the && isn't even considered.
Hi, while I was helping in some programming exercises, there was this problem:
int i = 1, j = 1, k = 1;
printf("%d ", ++i || ++j && ++k);
printf("i:%d j:%d k:%d", i, j, k);
I checked...
Nope, when you do &i, you were getting a pointer to pointer to int.
why a int* ?
If you know you have to take one loop out, why don't you like, try it :)
it seems what you're instructor is expecting is something more easy, like asking for the numbers and operations separately, and have a cycle to do more operations.
you could try code::blocks (an IDE), it keeps the console window open, no need for extra code.
yep, was just thinking now and wasn't sounding right. you're right.