Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int **test(char *tab)
- {
- int **a = malloc(sizeof(int*) * 2);
- int b = 0;
- a[0] = &tab[0];
- b++;
- for (int i = 0; tab[i] != '\0'; i++) {
- if (tab[i] == 42){
- a[b] = &tab[i + 1];
- }
- }
- return (a);
- }
- void print(int **a, int nbr)
- {
- for (int j = 0; j < nbr; j++) {
- printf("%c\n", *a[j]);
- }
- }
- int main()
- {
- char *tab = malloc(sizeof(char) * 1024);
- int **ptr;
- scanf("%s", tab);
- //printf("%s %c\n", tab, tab[0]);
- ptr = test(tab);
- print(ptr, 2); // faire le test avec 2 étoile car j'avais pas l'autre tp poour le config
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement