d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Random C Questions
Add Reply New Topic New Poll
Member
Posts: 24,101
Joined: Nov 8 2007
Gold: 5,561.70
Oct 10 2012 11:06am
Just studying old exams, got some questions.



My output:

2)
a. 10
b. 0
c. 2 (why is this 2?)
d. unknown (prints to address &a)
e. Not sure?
f. Not sure?


And another problem:

1-c. Assume that s and t are both valid strings and both end with a null character. Under what circumstances
will the expression strlen(s) - strlen(t) produce inconsistent or incorrect results? And
how can the problem be avoided?

I believe the null character isn't included in the calculation for strlen(), so I'm not really sure what scenario this would cause issues.

This post was edited by lopelurag on Oct 10 2012 11:07am
Member
Posts: 24,101
Joined: Nov 8 2007
Gold: 5,561.70
Oct 10 2012 11:40am
Update on #2:

b ) 11
f) unknown (since what your incrementing just points to an address &p?)
e) still not sure

This post was edited by lopelurag on Oct 10 2012 11:40am
Member
Posts: 24,101
Joined: Nov 8 2007
Gold: 5,561.70
Oct 10 2012 02:24pm
Nvm figured out how they work
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll