#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define MAX_ROWS 10
#define MAX_COLS 10
static char map[10][10];
void sin1(char map[][MAX_COLS]); 
void sin2(void);
void sin3(char map[][MAX_COLS]);
int main(void)
{  
   system("chcp 1253 >nul ");
   FILE *fileptr;
  
   char myColchar,apantisi,map[MAX_ROWS][MAX_COLS];
   int metritis1=0,apotelesma,myColnum=1,myrow=1,k,a,l,c,row, col;
   char r,fileRow[MAX_COLS + 2]; // account for newline and NULL
   
   printf("dose tin diataksi me ton arithmo pou epithymeis(1/2): \n");
   scanf("%d",&k);//edo tha iparxei sinartisi pou tha pairnei to k os parametro kai tha exei void epistrofi...
   while (k!=1 && k!=2){
         printf("ekanes lathos dose ksana tin diataksi me ton arithmo pou epithymeis(1/2): \n");
         scanf("%d",&k);}
   if (k==1){
        fileptr = fopen("1.txt", "r");}
   else if (k==2){
        fileptr=fopen("2.txt","r");}     
   else {
        printf("de dosate sosto\n");}
   if (fileptr == NULL)
      {
           perror("File Open Error");
           return -1;
      }
   else if (fileptr!=NULL){
   printf(" A B C D E F G H I J\n");   
   printf("--------------------- \n");   
   for (row = 0; row < MAX_ROWS; row++)
      {  
         fgets(fileRow, sizeof(fileRow), fileptr);
         
         printf("|");
         for (col = 0; col < MAX_COLS; col++){
              
              map[row][col] = fileRow[col];
              if (map[row][col]=='.'){
                                   map[row][col]=' ';}
              printf("%c",map[row][col]);
              printf("|");}
              printf("%d",row+1);
         
              printf("\n");
              printf("--------------------- \n");     
      }}
      
   printf("\nse periptosi pou ekteleite voli patiste <<N>> allios <<O>>: \n");
   printf("Ektelesi Volis (N/O): \n");
   scanf("%s",&apantisi);
   if (apantisi=='N'){
                     sin2();
                                             
                           
                                                                 

                     

                    
                    

                     
                     }
   else if (apantisi=='O'){
                     sin3(map);       
                     sin1(map);                                                    
                    
                          }
   
   
   fclose(fileptr);
   
   system("pause");
// now you have the map loaded,

      // so do the rest of your program
   return 0;
}
//*****************************************************************************************************************************
void sin1(char map[][MAX_COLS])
{    
     int row,col;
     for (row = 0; row < MAX_ROWS; row++)
      {  
          printf("|");
          for (col = 0; col < MAX_COLS; col++){
              printf("%c",map[row][col]);
              printf("|");}
          printf("%d",row+1);
          printf("\n");
              printf("--------------------- \n");     
      }
}

// *************************************************************************************************************************
void sin2(void)
{
                     int metritis1=0,l,c,apotelesma;                
                     
                     srand ( time(NULL) ); 
                     l = rand() % 10;
                     c = rand() % 10;
                     c=65+c;
                     l=l+1;
                     printf("Katastasi: Ektelesi Volis\n");
                     printf("sintetagmenes ekserxomenis volis: %c%d\n",c,l);
                     printf("Apotelesma ektelestheisas volis(Patiste <<1>> gia eystoxi kai <<2>> gia astoxi)\n");
                     printf("Voli %c %d: \n",c,l);
                     scanf("%d",&apotelesma);
                     while (apotelesma!=1 && apotelesma!=2){
                           printf("Apotelesma ektelestheisas volis(Patiste <<1>> gia eystoxi kai <<2>> gia astoxi)\n");
                           printf("Voli %c %d: \n",c,l);
                           scanf("%d",&apotelesma);}
                     if (apotelesma==1){
                                        metritis1++;
                                        }
                     else if (apotelesma==2){
                          }
}                         

//****************************************************************************************************************************

void sin3(char map[][MAX_COLS])
{
                    char myColchar;
                    int myColnum,myrow,col,row;
                    
                     printf("Katastasi: Lipsi Volis\n");
                     printf("Sintetagmenes eiserxomenis Volis: \n");
                     scanf("%s %d", &myColchar,&myrow);
                     myColnum = (int)myColchar;
                     if(myColnum >= 97){
                          myColnum = myColnum - 97;}
                     else if((myColnum >=65) && (myColnum <=90)){
                          myColnum = myColnum - 65;}
                       col = myColnum;
                       row = myrow - 1; // Need to compensate because array starts at 0.      
                     if (map[row][col]==' '){
                          map[row][col]='X';
                          printf("Apotelesma eiserxomenis volis: Anepityxis\n"); }               
                     else if (map[row][col]=='Ð'){
                          map[row][col]='ð';}                          
                     else if (map[row][col]=='Í'){ 
                          map[row][col]='í'; } 
                     else if (map[row][col]=='Ê'){     
                          map[row][col]='ê';}
                     else if (map[row][col]=='Ö'){  
                          map[row][col]='ö';}
                     else if (map[row][col]=='Õ'){     
                          map[row][col]='õ';}  
                     if (map[row][col]!='X'){
                          printf("Apotelesma eiserxomenis volis: Epityxis\n");}        
}

the compiler doesn't show any errors but if the user enters 1 and then O then the function sin3 has something that causes error window that says that the memory is not able to read....can u tell me what is wrong?i mean i tried it too many times but i cant see what is wrong...all i want is tha the sin3 function will determine whether or not there is a ship in the map[row][col] and then change the map[row][col] with another symbol...but also i want when the sin3 ends that the changes will be applied to the map array to use them later in the program....can u tranform my code?

what i just need is that whatever happens in the function sin3 and transforms array to change the current array and print it with sin1(map) in main program.....can my sin3 function return the map?

shouldn't it be entered as "O" and then "1" since the column is the letter, and in the scanf, your column letter is being entered first.

i see that there can easily be confusion with this because your array is structured such that the row is indicated first, not the column. in the traditional game, the coordinates are called out like "A 1" or "B 2" with the column letter in the first position.

but in any event, even if it is being entered correctly, "O" is the 15th letter of the alphabet (column index = 14), and you dont have that big of an array

or am i missing something?

i am kinda lost too can u change my code which is up and make it correct cause i am confused....

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define MAX_ROWS 10
#define MAX_COLS 10
void sin1(char map[][MAX_COLS]); 
void sin2(void);
int main(void)
{  
   system("chcp 1253 >nul ");
   FILE *fileptr;
  
   char myColchar,apantisi,map[MAX_ROWS][MAX_COLS];
   int metritis1=0,apotelesma,myColnum=1,myrow=1,k,a,l,c,row, col;
   char r,fileRow[MAX_COLS + 2]; // account for newline and NULL
   
   printf("dose tin diataksi me ton arithmo pou epithymeis(1/2/3): \n");
   scanf("%d",&k);//edo tha iparxei sinartisi pou tha pairnei to k os parametro kai tha exei void epistrofi...
   while (k!=1 && k!=2 && k!=3){
         printf("ekanes lathos dose ksana tin diataksi me ton arithmo pou epithymeis(1/2): \n");
         scanf("%d",&k);}
   if (k==1){
        fileptr = fopen("1.txt", "r");}
   else if (k==2){
        fileptr=fopen("2.txt","r");}     
   else if (k==3){
        fileptr=fopen("3.txt","r");}
   if (fileptr == NULL)
      {
           perror("File Open Error");
           return -1;
      }
   else if (fileptr!=NULL){
   printf(" A B C D E F G H I J\n");   
   printf("--------------------- \n");   
   for (row = 0; row < MAX_ROWS; row++)
      {  
         fgets(fileRow, sizeof(fileRow), fileptr);
         
         printf("|");
         for (col = 0; col < MAX_COLS; col++){
              
              map[row][col] = fileRow[col];
              if (map[row][col]=='.'){
                                   map[row][col]=' ';}
              printf("%c",map[row][col]);
              printf("|");}
              printf("%d",row+1);
         
              printf("\n");
              printf("--------------------- \n");     
      }}
      
   printf("\nse periptosi pou ekteleite voli patiste <<N>> allios <<O>>: \n");
   printf("Ektelesi Volis (N/O): \n");
   scanf("%s",&apantisi);
   if (apantisi=='N'){
                     sin2();
                                             
                           
                                                                 

                     

                    
                    

                     
                     }
   else if (apantisi=='O'){
                     
                           
                      printf("Katastasi: Lipsi Volis\n");
                      printf("Sintetagmenes eiserxomenis Volis: \n");
                      scanf("%s %d", &myColchar,&myrow);
                      
                      myColnum = (int)myColchar;
                      if(myColnum >= 97){
                          myColnum = myColnum - 97;}
                      else if((myColnum >=65) && (myColnum <=90)){
                          myColnum = myColnum - 65;}
                       col = myColnum;
                       row = myrow - 1; // Need to compensate because array starts at 0.      
                      if (map[row][col]==' '){
                          map[row][col]='X';
                          printf("Apotelesma eiserxomenis volis: Anepityxis\n"); }               
                      else if (map[row][col]=='Ð'){
                          map[row][col]='ð';}                          
                      else if (map[row][col]=='Í'){ 
                          map[row][col]='í'; } 
                      else if (map[row][col]=='Ê'){     
                          map[row][col]='ê';}
                      else if (map[row][col]=='Ö'){  
                          map[row][col]='ö';}
                      else if (map[row][col]=='Õ'){     
                          map[row][col]='õ';}  
                      if (map[row][col]!='X'){
                          printf("Apotelesma eiserxomenis volis: Epityxis\n");}                     
                      sin1(map);                                                    
                    
                          }
   
   
   fclose(fileptr);
   
   system("pause");
// now you have the map loaded,

      // so do the rest of your program
   return 0;
}

void sin1(char map[][MAX_COLS])
{    
     int row,col;
     for (row = 0; row < MAX_ROWS; row++)
      {  
          printf("|");
          for (col = 0; col < MAX_COLS; col++){
              printf("%c",map[row][col]);
              printf("|");}
          printf("%d",row+1);
          printf("\n");
              printf("--------------------- \n");     
      }
}


void sin2(void)
{
                     int metritis1=0,l,c,apotelesma;                
                     
                     srand ( time(NULL) ); 
                     l = rand() % 10;
                     c = rand() % 10;
                     c=65+c;
                     l=l+1;
                     printf("Katastasi: Ektelesi Volis\n");
                     printf("sintetagmenes ekserxomenis volis: %c%d\n",c,l);
                     printf("Apotelesma ektelestheisas volis(Patiste <<1>> gia eystoxi kai <<2>> gia astoxi)\n");
                     printf("Voli %c %d: \n",c,l);
                     scanf("%d",&apotelesma);
                     while (apotelesma!=1 && apotelesma!=2){
                           printf("Apotelesma ektelestheisas volis(Patiste <<1>> gia eystoxi kai <<2>> gia astoxi)\n");
                           printf("Voli %c %d: \n",c,l);
                           scanf("%d",&apotelesma);}
                     if (apotelesma==1){
                                        metritis1++;
                                        }
                     else if (apotelesma==2){
                          }
}

i want in the upper code to put the else if(apantisi='O') loop contents to a function ...can anyone help?and give the how?(pliz change my code)

i am kinda lost too can u change my code which is up and make it correct cause i am confused....

that's not how it works here

commented: Can I get an AMEN! :) +1

i know but i really cant make it up in my mind....so even an example would help i mean in my mind my code is right but windows say no.....

i know but i really cant make it up in my mind....so even an example would help i mean in my mind my code is right but windows say no.....

If I were looking for help on an English programming forum, I'd be sure to translate my program into English, to help them understand it.

Have you considered helping us to help you?

in my mind my code is right but windows say no.....

You want to check your scanf() usage. Most of them seem to be right but some are dangerously wrong.
For example;

// A single char
char apantisi;
...
// '%s' expects an array of char (i.e. a string), not a single char 
scanf("%s",&apantisi);

Instead that should be

// A single char
char apantisi;
// Use '%c' for a single char 
scanf("%c", &apantisi);

Fixing all these scanf() errors (i.e. scanf()ing a single char) should get rid of your program's crashes.

actually i think you are wrong.the error is not there if i change it instead it cant even scan at allo for a character.so the real error is in the sin3 function but i cant get it exactly....guys shall i translate my code to english?would that be easier to help me...?

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define MAX_ROWS 10
#define MAX_COLS 10
static char map[10][10];
void sin1(char map[][MAX_COLS]); 
void sin2(void);
void sin3(char map[][MAX_COLS]);
int main(void)
{  
   system("chcp 1253 >nul ");
   FILE *fileptr;
  
   char myColchar,apantisi,map[MAX_ROWS][MAX_COLS];
   int proti,metritis1=0,apotelesma,myColnum=1,myrow=1,k,a,l,c,row, col;
   char r,fileRow[MAX_COLS + 2]; // account for newline and NULL
   
   printf("give the ship structure you want(1/2/3): \n");
   scanf("%d",&k);//edo tha iparxei sinartisi pou tha pairnei to k os parametro kai tha exei void epistrofi...
   while (k!=1 && k!=2 && k!=3){
         printf("you made a mistake please give me again(1/2): \n");
         scanf("%d",&k);}
   if (k==1){
        fileptr = fopen("1.txt", "r");}
   else if (k==2){
        fileptr=fopen("2.txt","r");}     
   else if (k==3){
        fileptr=fopen("3.txt","r");}
   if (fileptr == NULL)
      {
           perror("File Open Error");
           return -1;
      }
   else if (fileptr!=NULL){
   printf(" A B C D E F G H I J\n");   
   printf("--------------------- \n");   
   for (row = 0; row < MAX_ROWS; row++)
      {  
         fgets(fileRow, sizeof(fileRow), fileptr);
         
         printf("|");
         for (col = 0; col < MAX_COLS; col++){
              
              map[row][col] = fileRow[col];
              if (map[row][col]=='.'){
                                   map[row][col]=' ';}
              printf("%c",map[row][col]);
              printf("|");}
              printf("%d",row+1);
         
              printf("\n");
              printf("--------------------- \n");     
      }}
      
   printf("\nif you are the one who fires press N or else O \n");
   printf("shot fire? (N/O): \n");
   scanf("%s",&apantisi);
   if (apantisi=='N'){
                     proti=2; 
                     sin2();
                                              
                           
                                                                 

                     

                    
                    

                     
                     }
   else if (apantisi=='O'){
                     proti=3;
                     sin3(map);
                                                                         
                    
                          }
   
   
         
   fclose(fileptr);
   
   system("pause");
// now you have the map loaded,

      // so do the rest of your program
   return 0;
}
//*****************************************************************************************************************************
void sin1(char map[][MAX_COLS])
{    
     int row,col;
     for (row = 0; row < MAX_ROWS; row++)
      {  
          printf("|");
          for (col = 0; col < MAX_COLS; col++){
              printf("%c",map[row][col]);
              printf("|");}
          printf("%d",row+1);
          printf("\n");
              printf("--------------------- \n");     
      }
}

// *************************************************************************************************************************
void sin2(void)
{
                     int metritis1=0,l,c,apotelesma;                
                     
                     srand ( time(NULL) ); 
                     l = rand() % 10;                     
                     c = rand() % 10;
                     
                     c=65+c;
                     l=l+1;
                     printf("Condition:Open Fire\n");
                     printf("coordinates of firing shot: %c%d\n",c,l);
                     printf("result of shot(Press <<1>> if you found target or <<2>> if you didn't)\n");
                     printf("Shot %c %d: \n",c,l);
                     scanf("%d",&apotelesma);
                     while (apotelesma!=1 && apotelesma!=2){
                           printf("result of shot(Press <<1>> if you found target or <<2>> if you didn't)\n");
                           printf("Shot %c %d: \n",c,l);
                           scanf("%d",&apotelesma);}
                     if (apotelesma==1){
                                        metritis1++;
                                        }
                     else if (apotelesma==2){
                          }
}                         

//****************************************************************************************************************************

void sin3(char map[][MAX_COLS])
{
                     char myColchar;
                     int myColnum=1,myrow,col,row;
                    
                     printf("Condition :Incoming shots\n");
                     printf("Coordinates of incoming shot: \n");
                     scanf("%s %d", &myColchar,&myrow);
                     myColnum = (int)myColchar;
                     if(myColnum >= 97){
                          myColnum = myColnum - 97;}
                     else if((myColnum >=65) && (myColnum <=90)){
                          myColnum = myColnum - 65;}
                       col = myColnum;
                       row = myrow - 1; // Need to compensate because array starts at 0.      
                     if (map[row][col]==' '){
                          map[row][col]='X';
                          printf("Result of incoming: Unsuccessful\n"); }               
                     else if (map[row][col]=='Ð'){
                          map[row][col]='ð';}                          
                     else if (map[row][col]=='Í'){ 
                          map[row][col]='í'; } 
                     else if (map[row][col]=='Ê'){     
                          map[row][col]='ê';}
                     else if (map[row][col]=='Ö'){  
                          map[row][col]='ö';}
                     else if (map[row][col]=='Õ'){     
                          map[row][col]='õ';}  
                     if (map[row][col]!='X'){
                          printf("Result of incoming shot:Success\n");}        
}

here is in english i just need to change the sin3 function cause in there something is wrong and the memory of system suffers.....but i dont get it if i use the sin3 function contents and put the in the if statement in the main program it works well...instead when i want to create the sin3 it does not....

in the sin3 function can i return the new array map contents to the main program?if yes how?

here is in english i just need to change the sin3 function cause in there something is wrong and the memory of system suffers

Could it be ..

scanf("%s %d", &myColchar,&myrow);

What do you think?
;)

i think that this is ok with the scanf...it read the char exactly....i have donw this before...the problem is why the sin3 function doesn;t work....

i think that this is ok with the scanf...it read the char exactly....i have donw this before...the problem is why the sin3 function doesn;t work....

Alright, now please understand that what you are doing regarding scanf()/a char , is just downright wrong (you are corrupting the program's memory, believe it or not). If you don't fix those issues, simply expect most anything in terms of your program's behaviour/outcome.

commented: Yes +4

Could it be ..

scanf("%s %d", &myColchar,&myrow);

What do you think?
;)

Mariosbikos -- slow down, please! You're ignoring perfectly good advice like the one above, from mitrmkar. myColchar is a char, and a char can never be a string, since it can't have enough room for an end of string char: '\0'.

So fix your scanf()'s, and leave the other stuff alone for now. Using scanf() for char's, is trickier than it looks, so I'm going to teach you how to do that, correctly.

When you enter anything with scanf(), you hit enter key at the end, so the keyboard buffer (KB), has a newline on the end of it.

For number scanf() (%d), that's no problem, because scanf() will pass right over any newline it runs into from the KB.

For char's, it's a WAY different story. The scanf() see's a '\n' (newline char), and say's "OK, I've got my char, leaving now", and it looks like your scanf() line of code was skipped entirely.

So, the thing to do is to pull the newline char's, after every scanf(), (when you have a char scanf() somewhere in the program), with a getchar(). Each getchar() will remove ONE char, and if you use it like this, it will do the job:

char ch;
int n;

scanf("%d", &n); //we get an int, but left a newline in the KB
getchar();     //we pull the newline char off the KB
scanf("%c", &ch); //now we can get our char variable, correctly

Without the getchar(), the second scanf(), will get "skipped" and ch will have nothing but a newline char in it's value.

Wow you were right....this was really the problem....one more question if i want to get first the char and then the number insted....how could that happen?i mean i cant have

getchar(); //we pull the newline char off the KB
scanf("%c", &ch);
scanf("%d", &n);
can i?

char myColchar;
                     int myColnum,myrow,col,row;
                    
                     printf("Katastasi: Lipsi Volis\n");
                     printf("Sintetagmenes eiserxomenis Volis: \n");
                     scanf("%d", &myrow);
                     getchar();
                     scanf("%c", &myColchar);
                     
                     myColnum = (int)myColchar;
                     printf("myColnum is %d\n",myColnum);
                     if(myColnum >= 97){
                          myColnum = myColnum - 97;}
                     else if((myColnum >=65) && (myColnum <=90)){
                          myColnum = myColnum - 65;}
                     col = myColnum;
                     row = myrow - 2;

and there is another error with %c you guys say....in the upper part of the code if i put myColchar as A or B or anything then the myColnum gets the price 10 insted of 65 for A and 66 for B etc.....what can i do for this?before the change with scanf it worked but now it does not....why?

never mind i found wheri was wrong thnx guys u really helped me....!!!!
yet there is still the problem how can the user enters firstly the char and then the number with the same result.....any thoughts?

never mind i found wheri was wrong thnx guys u really helped me....!!!!
yet there is still the problem how can the user enters firstly the char and then the number with the same result.....any thoughts?

If you have one getchar() after each scanf(), then you know that there is no newline still in the KB (unless the player's cat walked across the keyboard ;) )

So getting the char first, will be no trouble:

scanf("%c", &ch);

and if you're next scanf() is for a number, then you don't need any

getchar(); //not needed at all
scanf("%d", &number);

because scanf() will pull off the newline char, and keep right on going, to find the number behind it, in the KB.

It's a bit confusing, but you get used to it - but it shows one big reason why scanf() is not a good choice for a real robust user input function.

printf("Katastasi: Lipsi Volis\n");
                     printf("Sintetagmenes eiserxomenis Volis: \n");
                     scanf("%c", &myColchar);
                     scanf("%d", &myrow);
                     
                     
                     myColnum = (int)myColchar;

u mean that if i do this like this un the upper code it will be ok to enter A1 for example?cause i tried and the problem comes back....

The above looks wrong however.

For myColchar, You need to

1) change any lowercase letter the user may enter, to uppercase: use toupper() for that

2) subtract 'A' from your myColchar:, to make C into a 3, etc.: myColchar -= 'A';

The cast to an int doesn't do what you think if does. It just changes the SIZE of data, not the value. So if myColchar == 'A', the cast would leave you with 65 - (the ascii value of 'A'), which is the same value it had before the cast. Only the sizeof(myColchar) would have changed.

Then please post your code for any further bugs you find, so I can look at updated code, instead of old stuff.

Marios, if you'll post a sample input file for your program, I can test your program out, and see what's up with it.

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define MAX_ROWS 10
#define MAX_COLS 10
static char map[10][10];
void sin1(char map[][MAX_COLS]); 
void sin2(void);
void sin3(char map[][MAX_COLS]);
int main(void)
{  
   system("chcp 1253 >nul ");
   FILE *fileptr;
  
   char myColchar,apantisi,map[MAX_ROWS][MAX_COLS];
   int metritis1=0,metritis2=0,apotelesma,myColnum=1,myrow=1,k,a,l,c,row, col;
   char r,fileRow[MAX_COLS + 2]; // account for newline and NULL
   
   printf("dose tin diataksi me ton arithmo pou epithymeis(1/2/3): \n");
   scanf("%d",&k);//edo tha iparxei sinartisi pou tha pairnei to k os parametro kai tha exei void epistrofi...
   while (k!=1 && k!=2 && k!=3){
         printf("ekanes lathos dose ksana tin diataksi me ton arithmo pou epithymeis(1/2): \n");
         scanf("%d",&k);}
   if (k==1){
        fileptr = fopen("1.txt", "r");}
   else if (k==2){
        fileptr=fopen("2.txt","r");}     
   else if (k==3){
        fileptr=fopen("3.txt","r");}
   if (fileptr == NULL)
      {
           perror("File Open Error");
           return -1;
      }
   else if (fileptr!=NULL){
   printf(" A B C D E F G H I J\n");   
   printf("--------------------- \n");   
   for (row = 0; row < MAX_ROWS; row++)
      {  
         fgets(fileRow, sizeof(fileRow), fileptr);
         
         printf("|");
         for (col = 0; col < MAX_COLS; col++){
              
              map[row][col] = fileRow[col];
              if (map[row][col]=='.'){
                                   map[row][col]=' ';}
              printf("%c",map[row][col]);
              printf("|");}
              printf("%d",row+1);
         
              printf("\n");
              printf("--------------------- \n");     
      }}
      
   printf("\nse periptosi pou ekteleite voli patiste <<N>> allios <<O>>: \n");
   printf("Ektelesi Volis (N/O): \n");
   getchar();
   scanf("%c", &apantisi);
   if (apantisi=='N'){
                      
                     sin2();
                     sin1(map);
                     while (1){
                           sin3(map);
                           sin1(map);
                           if (metritis1==17 || metritis2==17){break;}
                           sin2();
                           sin1(map);
                           if (metritis1==17 || metritis2==17){break;}
                           }
                                                    
                           
                                                                 

                     

                    
                    

                     
                     }
   else if (apantisi=='O'){
                  
                     sin3(map);
                     sin1(map);
                     while (1){
                           sin2();
                           sin1(map);
                           if (metritis2==17 || metritis1==17){break;}
                           sin3(map);
                           sin1(map);
                           if (metritis2==17  || metritis1==17){break;}
                           }
               
                                                                         
                    
                          }
   
   
         
   fclose(fileptr);
   
   system("pause");
// now you have the map loaded,

      // so do the rest of your program
   return 0;
}
//*****************************************************************************************************************************
void sin1(char map[][MAX_COLS])
{    
     int row,col;
     printf(" A B C D E F G H I J\n");   
     printf("--------------------- \n");  
     for (row = 0; row < MAX_ROWS; row++)
      {  
          printf("|");
          for (col = 0; col < MAX_COLS; col++){
              printf("%c",map[row][col]);
              printf("|");}
          printf("%d",row+1);
          printf("\n");
              printf("--------------------- \n");     
      }
}

// *************************************************************************************************************************
void sin2(void)
{
                     int metritis1,l,c,apotelesma;                
                     
                     srand ( time(NULL) ); 
                     l = rand() % 10;                     
                     c = rand() % 10;
                     
                     c=65+c;
                     l=l+1;
                     printf("Katastasi: Ektelesi Volis\n");
                     printf("sintetagmenes ekserxomenis volis: %c%d\n",c,l);
                     printf("Apotelesma ektelestheisas volis(Patiste <<1>> gia eystoxi kai <<2>> gia astoxi)\n");
                     printf("Voli %c %d: \n",c,l);
                     scanf("%d",&apotelesma);
                     while (apotelesma!=1 && apotelesma!=2){
                           printf("Apotelesma ektelestheisas volis(Patiste <<1>> gia eystoxi kai <<2>> gia astoxi)\n");
                           printf("Voli %c %d: \n",c,l);
                           scanf("%d",&apotelesma);}
                     if (apotelesma==1){
                                        metritis1++;
                                        }
                     else if (apotelesma==2){
                          }
}                         

//****************************************************************************************************************************

void sin3(char map[][MAX_COLS])
{
                     char myColchar;
                     int myColnum,metritis2,myrow,col,row;
                    
                     printf("Katastasi: Lipsi Volis\n");
                     printf("Sintetagmenes eiserxomenis Volis: \n");
                     
                     scanf("%d", &myrow);
                     getchar();
                     scanf("%c", &myColchar);
                     
                     myColnum = (int)myColchar;
                 
                     if(myColnum >= 97){
                          myColnum = myColnum - 97;}
                     else if((myColnum >=65) && (myColnum <=90)){
                          myColnum = myColnum - 65;}
                     col = myColnum;
                     row = myrow - 1; // Need to compensate because array starts at 0.      
                     if (map[row][col]==' '){
                          map[row][col]='X';
                          printf("Apotelesma eiserxomenis volis: Anepityxis\n"); }               
                     else if (map[row][col]=='Ð' || map[row][col]=='Í' || map[row][col]=='Ê' || map[row][col]=='Ö' || map[row][col]=='Õ'){
                          map[row][col]='*';
                          }                          
                     
                     if (map[row][col]!='X'){
                          printf("Apotelesma eiserxomenis volis: Epityxis\n");
                          metritis2++;}        
}

here it is...

i want for the user to be able to write first the char and then the number to hit e.g A 5 insted of 5 A which is now?but i dont know how exactly...i mean getchar scanf?

I have already taken the English version, of your program, and made several corrections to it.

But I can't test it to see if it'll work, without the 1.txt, 2.txt, and or 3.txt file(s).

Can you post?

Just make a txt file with 10 rows and 10 columns like

...Π......
.Ν.Π......
.Ν........
.Ν....Κ...
.Ν....Κ...
.Ν....Κ...
...ΦΦΦΦ...
........Υ.
........Υ.
........Υ.

only with dots and these letters 10 rows and 10 columns...try it and tell me

What does "apantisi" and "apotelesma", mean?

Guys how can i delete the current thread cause many guys take my code.....???

adak apantisi means answer and apotelesma means result

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.