all the printf() before it work but the magic is that also all the printf() after it work!!!
it's not possibile!!!
Here the code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
FILE *fp;
void Anagramma(char A[30],char B[30]);
int main()
{
char A[30];
printf("Inserisci la stringa: ");
gets(A);
fp=fopen("Result.txt","w"); //open the file
Anagramma(A,""); //call anagramma
fclose(fp); //close the file
printf("I'M A MAGIC PRINTF()"); // this printf NOT WORK
printf("I'M NOT MAGIC BUT I WORK");
getch();
return 0;
}
void Anagramma(char A[30],char B[30])
{
char temp[2];
int i,k;
if(strlen(A)==0) //se la stringa A Š vuota
fprintf(fp,"%s\n",B); //scrivo nel file la stringa B
else
{
for(i=0;i<strlen(A);i++)
{
temp[0]=A[i]; //in temp salvo il carattere i-esimo di A
temp[1]=0;
for(k=i;k<strlen(A);k++)
A[k]=A[k+1];
Anagramma(A,strcat(B,temp));
B[strlen(B)-1]=0; //elimino temp da B
for(k=strlen(A);k>=i;k--)
A[k+1]=A[k];
A[i]=temp[0];
}
}
}
Thanks
This post has been edited by Oscar53: 01 June 2008 - 01:14 AM

New Topic/Question
Reply




MultiQuote







|