I'm totally new student for c++ and finished watching some c++ tutorials for 5 - 6 hours long.
I didn't know what to study, so decided to work watch one of the tutorials of c++ and kinda following what the youtuber is doing.
While I'm working on it, I didn't get few lines of code which are
int main( int argc, char *argv[])
grid[x][y] = to_string(number).c_str()[0];
First of all, I didn't know we can put some parameters inside of main function parentheses and I don't get
to_string(number).c_str()[0]
Can someone explain these?
#include <iostream>
#define GRID_SIZE 3
using namespace std;
int main( int argc, char *argv[]){
char grid[GRID_SIZE][GRID_SIZE];
int number = 1;
for (int x = 0; x < GRID_SIZE; x++){
for(int y = 0; y < GRID_SIZE; y++){
grid[x][y] = to_string(number).c_str()[0];
number += 1;
}
}
printf("\n------------\n");
for (int x = 0; x < GRID_SIZE; x++){
for (int y = 0; y < GRID_SIZE; y++){
printf(" %c |", grid[x][y]);
}
printf("\n------------\n");
}
return 0;
}