Jump to content
cifratorul

[easy] C trick

Recommended Posts

Se da programul:

#include <stdio.h>

#include <conio.h>

int main ()

{

char * s = "start;*s=\"startcopiereint*startevalregx\x2ex86concon;rm-rf";

char*p=s;

char c;

// NU editati for-ul ce urmeaza

for ( c=p[0]; c; c=*(++p) )

{

printf("%c", c);

}

_getch();

}

Cum ati modifica acest program astfel incat sa afiseze "rstcenter.com" ?

PS: "concon" e legat fara nici un spatiu intre o si n un inteleg de unde mai apare un spatiu.

Edited by cifratorul
  • Upvote 1
Link to comment
Share on other sites

R?spunsul corect



#include <stdio.h>
#include <conio.h>

int main ()
{
char *s ="start;*s=\"startcopiereint*startevalregx\x2ex86concon;rm-rf";
char **p=(char *)s+3;
char c;
// NU editati for-ul ce urmeaza
for ( c=p[0]; c; c=*(++p) )
{
printf("%c", c);
}
_getch();
}

Link to comment
Share on other sites

Sigur ca compileaza. Uite aici.

Sau pe windows cu CodeBlocks.

Sau pe linux


student@ubuntu:~/APD/lab1APD$ gcc geo.c -o geo
geo.c: In function ‘main’:
geo.c:7:14: warning: initialization from incompatible pointer type
geo.c:10:12: warning: assignment makes integer from pointer without a cast
geo.c:10:23: warning: assignment makes integer from pointer without a cast
student@ubuntu:~/APD/lab1APD$ ./geo
rstcenter.com

Sper ca nu folosesti BorlandC 3.1.

Offtopic: Acesta va fi ultimul meu post pe rstcenter care va fi scris fara diacritice. Adica ori le rezolvati, ori nu mai postez. M-am saturat sa dau post si sa pierd juma de mesaj, sa fiu nevoit sa il scriu din nou.

Edited by em
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...