c - Wierd output for string operation IDEONE -


Can someone tell me why this happens, what's wrong here:

Print the part of the string where the beginning of the string is given in the input to print the space and length.

Problem: When I run it devC ++ then everything runs fine and fine. When I run it in IDEON, unless the printf ("% s \ n", abc) does not print the entire string, the code generates an output [not from the character array];

---> When I do not use Printf ("% s \ n", ABC);

Includes # lt; Stdio.h & gt; # Include & lt; Ctype.h & gt; Int main () {long long int q; Int length = 0; Scanf ("% lld", & amp; quot;); Whereas (q--) {int location, cutlength = 0, k = 0, pos, plen = 0; Four ABCs [100001], [100001], C; While (1) {scanf ("% c", & amp; c); If (C == '+' || C == '?') Break; } If (C == '+') {scanf ("% d", and loc); Position = loc; Cutlength = length-loc; For (int i = loc; i & lt; = length-loc; i ++) [k ++] = abc [i] save; Scanf ("% c", & amp; c); While (! Islfa (C)) scan F ("% c", & amp; c); While (1) {if (! (Islfa (C)) break; ABC [loc ++] = c; Length ++; Scanf ("% c", & amp; c); } Length + = pos + cutlength; For (int i = 0; i

---> When I use printf ("% s \ n", abc);

code c == '?' Uses the array in the block ABC when it does not begin.

It looks like you should have the c == '+' / code> block in abc when you go to the next loop intentation. Although this is not true: Local is opened by ABC block , so each loop walking is destroyed and rebuilt.

Maybe it works on Dev-C ++ because there is no such inquiry, and every time it uses only one piece of memory again

I think that You want to move some or all variable declarations at the beginning of the loop, before the loop.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -