salut j'un un petit problem , j ai fait une fonction qui prend la string des numero
ex : 10,20,30,40 et fa diviser chaque numero et je fait le print , ca marche si je fait le print de string , mais moi je veux transforme la string en integer pour avoir
4 numero dans ceux exemple
10
20
30
40
que je les utilise apres dans une matrice , le probleme qu'en je fait la conversion il me transforme seulement le 1ere string qui est 10 .???


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<stdio.h>
#include<string.h>
#define sep ".,\"?"
#define line 100
 
 
int main()
{ 
  // int i;
  char *test;
  int valore;
  char *word;
  char linea[line];
  do{
    printf("line :  ");//printf("%d\n",i);
    fgets(linea,line,stdin);
    if(strlen(linea)>0){
      word=strtok(linea,sep);
      // printf(" %d\t",atoi(word));
      //  valore=atoi(word);
      while(word){ 
	// valore=atoi(word);      
	printf(" %d\t",atoi(word));
	printf("\n %s\t",word);
	word=strtok(NULL,sep);
      }
    }
  }
  while(strlen(linea)!=0);
  return 0;
}