Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ** main.c for colle3 in /home/dupard_e/rendus/Piscine_C_colles-Semaine_03
- **
- ** Made by Erwan Dupard
- ** Login <[email protected]>
- **
- ** Started on Sat Oct 25 14:07:34 2014 Erwan Dupard
- ** Last update Sat Oct 25 18:17:30 2014 Erwan Dupard
- */
- #include "my_struct.h"
- int main(int argc, char **argv)
- {
- char buff[BUFF_SIZE + 1];
- int len;
- while ((len = read(0, buff, BUFF_SIZE)) != 0)
- {
- printf("%d\n", len);
- detect(buff);
- //printf("x : %d && y : %d\n", get_x(buff), get_y(buff));
- }
- return (0);
- }
- int get_x(char *str)
- {
- int x;
- int i;
- x = 0;
- i = 0;
- while (str[i] != '\n')
- {
- x++;
- i++;
- }
- return (x);
- }
- int get_y(char *str)
- {
- int y;
- y = 0;
- while (*str != 0)
- {
- if (*str == '\n')
- y++;
- str++;
- }
- return (y);
- }
- void detect(char *str)
- {
- int x;
- int y;
- char *colle;
- x = get_x(str);
- y = get_y(str);
- if (*str == 'o')
- colle = my_strdup("[colle1-1]");
- if (*str == '/')
- colle = my_strdup("[colle1-2]");
- printf("%s %d %d\n", colle, x, y);
- }
Advertisement
Add Comment
Please, Sign In to add comment