Reputation: 9
I have this file and i Want to save in variables only the lines that dont start with //:
// Dimensoes da janela em termo de bolhas (largura e altura)
60 40
// Dimensão da bolha em pixeis (raio)
5
// dl – distancia para avaliação da colisão (percentagem do diametro)
0.95
// Numero de linhas inicias com bolhas
6
// Geração de uma nova linha de bolhas ao fim de N jogadas
10
Im not sure how i can do it. I've tryed with fscanf and fgets but im not doing it right thanks in advance
Upvotes: 0
Views: 545
Reputation: 332
You can try something like:
FILE * inputFile;
char str[256];
inputFile = fopen("fileName.txt", "r");
while(fgets(str, 256, inputFile) != NULL) {
if (str[0] == '/' && str[1] == '/') {
// Save string here
}
}
Upvotes: 1