[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
What does this script do? while (*(++c) != '\0');
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 23
Thread images: 2
File: 1445913210197.png (120 KB, 500x428) Image search: [Google]
1445913210197.png
120 KB, 500x428
What does this script do?
while (*(++c) != '\0');
>>
>>51277021
crash
>>
goes through a c style string
>>
>>51277021
can't tell without c's value. also, that most likely would segfault
>>
>>51277021
Advances c which is a pointer to char to the character with code 0 in the string that c is pointing to initially.
>>
File: _.jpg (10 KB, 264x198) Image search: [Google]
_.jpg
10 KB, 264x198
>Exit code: 0 (normal program termination)
>>
>>51277035
That would "most likely" work just fine when you use it correctly.
>>
>>51277046
Welp. This one makes 0 sense.

char *c="hello!";
while (*(++c) != '\0');


Here's how that shit can be used.
>>
>>51277068
/thread
>>
>>51277021
c isn't defined
>>
>>51277021
Assuming 'c' is C string. It won't anything useful.
>>
>>51277087
Will let you calculate length of a non-empty string. Pretty useful if you ask me.
>>
>>51277109
The loop contains nothing, therefore it does nothing. Of course you can use the statement for many things, but the exact code of OP does nothing.
>>
>>51277120
You are mistaken about that, anon. OP's code changes c.
>>
>>51277129
yeah, c increments, but what do you do with that if you don't have the starting reference? you lose it as soon as you increment it.
>>
>>51277149
>if you don't have the starting reference
Who told you I don't?
>>
>>51277154
OP's code lacks of it.
>>
>>51277158
Doesn't matter. OP's code is just an extract. You claimed the code does nothing and you were greatly mistaken about that. Then you moved the goalpost claiming it doesn't do nothing but you can't make use of what it does. You can.
>>
>>51277189
Oh well, I guess you are right then.
OP's code does something in the right context.
Better?
>>
>>51277195
Very much.
>>
>>51277200
Thank you.
>>
>>51277021

contact this goy. maybe he can edify you.
>>51272013
>>
It moves the pointer c forward until it's at a 0 byte.
Thread replies: 23
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.