cifratorul Posted October 9, 2011 Report Posted October 9, 2011 (edited) 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 October 10, 2011 by cifratorul 1 Quote
totti93 Posted October 9, 2011 Report Posted October 9, 2011 Fara sa modific stringul acela (Doar am lipit acel spatiu):#include <stdio.h>#include <conio.h>int main (){char * s = "start;*s=\"startcopiereint*startevalregx\x2ex86concon;rm-rf";char*p=s + 3;char c;for ( c=p[0]; c; c=*(p = p + 4) ){printf("%c", c);}_getch();} Quote
cifratorul Posted October 9, 2011 Author Report Posted October 9, 2011 si daca nu ai avea voie sa modifici decat o linie? (sa nu modifici for-ul deloc) Quote
Sturmf Posted October 10, 2011 Report Posted October 10, 2011 (edited) Uff e stricat Vbulletin-ul.... Edited October 10, 2011 by Sturmf Quote
em Posted October 10, 2011 Report Posted October 10, 2011 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();} Quote
cifratorul Posted October 10, 2011 Author Report Posted October 10, 2011 @em: pai cum zici tu nici nu se compileaza : error C2440: 'initializing' : cannot convert from 'char *' to 'char **' Quote
em Posted October 11, 2011 Report Posted October 11, 2011 (edited) Sigur ca compileaza. Uite aici.Sau pe windows cu CodeBlocks.Sau pe linuxstudent@ubuntu:~/APD/lab1APD$ gcc geo.c -o geogeo.c: In function ‘main’:geo.c:7:14: warning: initialization from incompatible pointer typegeo.c:10:12: warning: assignment makes integer from pointer without a castgeo.c:10:23: warning: assignment makes integer from pointer without a caststudent@ubuntu:~/APD/lab1APD$ ./georstcenter.comSper 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 October 11, 2011 by em Quote
cifratorul Posted October 11, 2011 Author Report Posted October 11, 2011 @em: ok. visualu' meu face urat si nu vrea sa faca conversia aia. pana la urma sa zicem ca merge. te bazezi ca un pointer are 4 bytes (si asta depinde de OS). puteai folosi direct un tip care are 4 bytes. Quote
em Posted October 11, 2011 Report Posted October 11, 2011 Adica asaint *p=s+3;Dar tot primesc un warning. Sunt curios daca acum iti merge in Visual. Quote