Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.87 KB | None | 0 0
  1.  
  2. /* ************************************************************************** */
  3. /* */
  4. /* ::: :::::::: */
  5. /* ft_strrev.c :+: :+: :+: */
  6. /* +:+ +:+ +:+ */
  7. /* By: msabwat <marvin@42.fr> +#+ +:+ +#+ */
  8. /* +#+#+#+#+#+ +#+ */
  9. /* Created: 2017/08/08 21:01:05 by msabwat #+# #+# */
  10. /* Updated: 2017/08/08 21:23:06 by msabwat ### ########.fr */
  11. /* */
  12. /* ************************************************************************** */
  13.  
  14. char *ft_strrev(char *str)
  15. {
  16. int i;
  17. int j;
  18.  
  19. i = 0;
  20. j = 0;
  21. while (str[i])
  22. {
  23. i++;
  24. }
  25. while (i >= 0)
  26. {
  27. str[i] = str[;
  28. i--;
  29. j++;
  30. }
  31. return (str);
  32. }
  33.  
  34. int main()
  35. {
  36. ft_strrev("testota");
  37. return (0);
  38. }
  39. ~
  40. ~
  41. ~
  42. ~
  43. ~
  44. ~
  45. ~
  46. ~
  47. ~
  48. ~
  49. ~
  50. ~
  51. ~
  52. ~
  53. ~
  54. ~
  55. ~
  56. ~
  57. ~
  58. ~
  59. ~
  60. ~
  61. ~
  62. ~
  63. ~
  64. ~
  65. ~
  66. ~
  67. ~
  68. ~
  69. ~
  70. ~
  71. ~
  72. ~
  73. ~
  74. ~
  75. ~
  76. ~
  77. /* ************************************************************************** */
  78. ft_strlen.c
  79. e2r10p19% cd ..
  80. e2r10p19% ls
  81. ex00 ex01 ex02 ex03 ex04 ex05 ex06
  82. e2r10p19% mkdir ft_strrev.c
  83. e2r10p19% rm ft_strrev.c
  84. rm: ft_strrev.c: is a directory
  85. e2r10p19% rm -r ft_strrev.c
  86. e2r10p19% ls
  87. ex00 ex01 ex02 ex03 ex04 ex05 ex06
  88. e2r10p19% mkdir ex07
  89. e2r10p19% ls
  90. ex00 ex01 ex02 ex03 ex04 ex05 ex06 ex07
  91. e2r10p19% git add.
  92. git: 'add.' is not a git command. See 'git --help'.
  93.  
  94. Did you mean this?
  95. add
  96. e2r10p19% git add .
  97. e2r10p19% git log
  98. commit bc8621a0a645c3e64e0485a363048d5e21c66190
  99. Author: Mehdi m'hamed SABWAT <msabwat@e1r2p13.42.fr>
  100. Date: Mon Aug 7 22:24:43 2017 +0200
  101.  
  102. premiers pas
  103. e2r10p19% git status
  104. On branch master
  105. Your branch is up-to-date with 'origin/master'.
  106. Changes to be committed:
  107. (use "git reset HEAD <file>..." to unstage)
  108.  
  109. renamed: ft_ft.c -> ex00/ft_ft.c
  110. new file: ex01/ft_ultimate_ft.c
  111. new file: ex02/ft_swap.c
  112. new file: ex03/ft_div_mod.c
  113. new file: ex04/ft_ultimate_div_mod.c
  114. new file: ex05/ft_putstr.c
  115. new file: ex06/ft_strlen.c
  116.  
  117. e2r10p19% git commit -m "avancement... ATTENTION pas verifie la norminette"
  118. [master 388fa44] avancement... ATTENTION pas verifie la norminette
  119. Committer: Mehdi m'hamed SABWAT <msabwat@e2r10p19.42.fr>
  120. Your name and email address were configured automatically based
  121. on your username and hostname. Please check that they are accurate.
  122. You can suppress this message by setting them explicitly. Run the
  123. following command and follow the instructions in your editor to edit
  124. your configuration file:
  125.  
  126. git config --global --edit
  127.  
  128. After doing this, you may fix the identity used for this commit with:
  129.  
  130. git commit --amend --reset-author
  131.  
  132. 7 files changed, 126 insertions(+), 3 deletions(-)
  133. rename ft_ft.c => ex00/ft_ft.c (84%)
  134. create mode 100644 ex01/ft_ultimate_ft.c
  135. create mode 100644 ex02/ft_swap.c
  136. create mode 100644 ex03/ft_div_mod.c
  137. create mode 100644 ex04/ft_ultimate_div_mod.c
  138. create mode 100644 ex05/ft_putstr.c
  139. create mode 100644 ex06/ft_strlen.c
  140. e2r10p19% git push
  141. vogsphere: (INFO) Transaction ID : 308efbac-6df8-4b21-a04e-615cb0e6b542
  142. vogsphere: (INFO) Please mention this ID in any ticket you create concerning this transaction
  143. vogsphere: (INFO) This transaction has been started at 2017-08-08 20:56:40, server time.
  144. vogsphere: (INFO) Rights will be determined using this time, so do NOT cut the connection.
  145. vogsphere: (INFO) It appears you are msabwat. If that's not true, check your Kerberos tickets (klist)
  146. vogsphere: (INFO) You have read and write rights on this repository
  147. Counting objects: 16, done.
  148. Delta compression using up to 4 threads.
  149. Compressing objects: 100% (9/9), done.
  150. Writing objects: 100% (16/16), 1.59 KiB | 0 bytes/s, done.
  151. Total 16 (delta 6), reused 0 (delta 0)
  152. To vogsphere.42.fr:intra/2017/activities/piscine_c_day_03/msabwat
  153. bc8621a..388fa44 master -> master
  154. e2r10p19% ls
  155. ex00 ex01 ex02 ex03 ex04 ex05 ex06 ex07
  156. e2r10p19% cd ex07
  157. e2r10p19% ls
  158.  
  159.  
  160. source /Users/msabwat/42-correction-jhalford/jhalford-corr-install.sh
  161. e2r10p19% ls
  162. e2r10p19% vim ft_strrev.c
  163. e2r10p19% git add .
  164.  
  165.  
  166. /* ************************************************************************** */
  167. /* */
  168. /* ::: :::::::: */
  169. /* ft_strrev.c :+: :+: :+: */
  170. /* +:+ +:+ +:+ */
  171. /* By: msabwat <marvin@42.fr> +#+ +:+ +#+ */
  172. /* +#+#+#+#+#+ +#+ */
  173. /* Created: 2017/08/08 21:01:05 by msabwat #+# #+# */
  174. /* Updated: 2017/08/08 22:01:09 by msabwat ### ########.fr */
  175. /* */
  176. /* ************************************************************************** */
  177.  
  178. char *ft_strrev(char *str)
  179. {
  180. int i;
  181. char *tab;
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227. i = 0;
  228. j = 0;
  229. while (str[i])
  230. {
  231. i++;
  232. }
  233. while (i >= 0)
  234. {
  235.  
  236. }
  237. return (str);
  238. }
  239.  
  240. int main()
  241. {
  242. ft_strrev("testota");
  243. return (0);
  244. }
  245. ~
  246. ~
  247. ~
  248. ~
  249. ~
  250. ~
  251. ~
  252. ~
  253. ~
  254. ~
  255. ~
  256. ~
  257. ~
  258. ~
  259. ~
  260. ~
  261. ~
  262. ~
  263. ~
  264. ~
  265. ~
  266. ~
  267. ~
  268. ~
  269. ~
  270. ~
  271. ~
  272. ~
  273. ~
  274. ~
  275. ~
  276. ~
  277. ~
  278. ~
  279. ~
  280. ~
  281. ~
  282. ~
  283. ~
  284. ~
  285. ~
  286. ~
  287. ~
  288. ~
  289. ~
  290. ~
  291. ~
  292. ft_strrev.c [+] 26,3-9 All
  293. -- INSERT --
  294.  
  295. Session Restored
  296.  
  297. Last login: Wed Aug 9 11:32:14 on console
  298. e1r2p3% atoi lkjhr98mnb88
  299. zsh: command not found: atoi
  300. e1r2p3% atoi man
  301. zsh: command not found: atoi
  302. e1r2p3% man atoi
  303. e1r2p3% atoi "jhkjhd545758kjhd54"
  304. zsh: command not found: atoi
  305. e1r2p3% atoi("jhkjhd545758kjhd54")
  306. zsh: unknown file attribute: j
  307. e1r2p3% atoi("545758")
  308. zsh: no matches found: atoi(545758)
  309. e1r2p3% clear
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333. ~
  334. ~
  335. ~
  336. ~
  337. ~
  338. ~
  339. ~
  340. ~
  341. ~
  342. ~
  343. ~
  344. ~
  345. ~
  346. ~
  347. ~
  348. ~
  349. ~
  350. ~
  351. ~
  352. ~
  353. ~
  354. ~
  355. ~
  356. ~
  357. ~
  358. ~
  359. ~
  360. ~
  361. ~
  362. ~
  363. ~
  364. ~
  365. ~
  366. ~
  367. ~
  368. ~
  369. ~
  370. ~
  371. ~
  372. ~
  373. ~
  374. ft_strrev.c 29,6-12 All
  375. "ft_strrev.c" 38L, 1138C written
  376. /* ************************************************************************** */
  377. /* */
  378. /* ::: :::::::: */
  379. /* ft_strrev.c :+: :+: :+: */
  380. /* +:+ +:+ +:+ */
  381. /* By: msabwat <marvin@42.fr> +#+ +:+ +#+ */
  382. /* +#+#+#+#+#+ +#+ */
  383. /* Created: 2017/08/08 21:01:05 by msabwat #+# #+# */
  384. /* Updated: 2017/08/09 12:07:34 by msabwat ### ########.fr */
  385. /* */
  386. /* ************************************************************************** */
  387.  
  388. char *ft_strrev(char *str)
  389. {
  390. int i;
  391. int j;
  392. char *revstr;
  393.  
  394. i = 0;
  395. j = 0;
  396. while (str[i])
  397. {
  398. i++;
  399. }
  400. while (i >= 0 && j < i)
  401. {
  402. revstr[j] = str[i];
  403. i--;
  404. j++;
  405. }
  406. return (str);
  407. }
  408.  
  409. int main()
  410. {
  411. ft_strrev("testota");
  412. return (0);
  413. }
  414. ~
  415. ~
  416. ~
  417. ~
  418. ~
  419. ~
  420. ~
  421. ~
  422. ~
  423. ~
  424. ~
  425. ~
  426. ~
  427. ~
  428. ~
  429. ~
  430. ~
  431. ~
  432. ~
  433. ~
  434. ~
  435. ~
  436. ~
  437. ~
  438. ~
  439. ~
  440. ~
  441. ~
  442. ~
  443. ~
  444. ~
  445. ~
  446. ~
  447. ft_strrev.c 29,6-12 All
  448. 1 /* ************************************************************** ************ */
  449. 2 /* */
  450. 3 /* ::: :::::::: */
  451. 4 /* ft_strrev.c :+: :+: :+: */
  452. 5 /* +:+ +:+ +:+ */
  453. 6 /* By: msabwat <marvin@42.fr> +#+ +:+ +#+ */
  454. 7 /* +#+#+#+#+#+ + #+ */
  455. 8 /* Created: 2017/08/08 21:01:05 by msabwat #+# #+# */
  456. 9 /* Updated: 2017/08/09 12:59:23 by msabwat ### ##### ###.fr */
  457. 10 /* */
  458. 11 /* ************************************************************** ************ */
  459. 12
  460. 13 #include <unistd.h>
  461. 14
  462. 15 void ft_putstr(char *str);
  463. 16
  464. 17 int ft_putchar(char c)
  465. 18 {
  466. 19 write(1, &c, 1);
  467. 20 return (0);
  468. 21 }
  469. 22
  470. 23 char *ft_strrev(char *str)
  471. 24 {
  472. 25 int i;
  473. 26 int j;
  474. 27
  475. 28 i = 0;
  476. 29 j = 0;
  477. 30 while (str[i])
  478. 31 {
  479. 32 i++;
  480. 33 }
  481. 34 char revstr[i];
  482. 35 while (i >= 0 )
  483. 36 {
  484. 37 revstr[j] = str[i];
  485. 38 ft_putchar(revstr[j]);
  486. 39 i--;
  487. 40 j++;
  488. 41 ft_putchar(i + 48);
  489. 42 ft_putchar(j + 48);
  490. 43 }
  491. 44 return (str);
  492. 45 }
  493. 46
  494. 47 int main()
  495. 48 {
  496. 49 char *string;
  497. 50
  498. 51 string = "testota";
  499. 52 ft_strrev(string);
  500. 53 ft_putstr(string);
  501. 54 return (0);
  502. 55 }
  503. ~
  504. ~
  505. ~
  506. ~
  507. ~
  508. ~
  509. ~
  510. ~
  511. ~
  512. ~
  513. ~
  514. ~
  515. ~
  516. ~
  517. ~
  518. ft_strrev.c 37,2-8 All
  519. "ft_strrev.c" 55L, 1365C written
  520.  
  521. Session Restored
  522.  
  523. Last login: Wed Aug 9 14:37:01 on console
  524. e1r2p3% ls
  525. a.out ft_putstr.c ft_strrev.c
  526. e1r2p3% ls
  527. a.out ft_putstr.c ft_strrev.c
  528. e1r2p3% clear
  529.  
  530.  
  531.  
  532.  
  533.  
  534. /* ************************************************************************** e1r2p3% ls
  535. a.out ft_putstr.c ft_strrev.c
  536. e1r2p3% vim ft_putstr.c
  537. e1r2p3% vim ft_strrev.c
  538. e1r2p3% cat ft_strrev.c
  539. /* ************************************************************************** */
  540. /* */
  541. /* ::: :::::::: */
  542. /* ft_strrev.c :+: :+: :+: */
  543. /* +:+ +:+ +:+ */
  544. /* By: msabwat <marvin@42.fr> +#+ +:+ +#+ */
  545. /* +#+#+#+#+#+ +#+ */
  546. /* Created: 2017/08/08 21:01:05 by msabwat #+# #+# */
  547. /* Updated: 2017/08/09 16:29:29 by msabwat ### ########.fr */
  548. /* */
  549. /* ************************************************************************** */
  550.  
  551.  
  552.  
  553. /* ************************************************************************** #include <unistd.h>
  554. #include <stdio.h>
  555. void ft_putstr(char *str);
  556.  
  557. int ft_putchar(char c)
  558. {
  559. write(1, &c, 1);
  560. return (0);
  561. }
  562.  
  563. char *ft_strrev(char *str)
  564. {
  565. int i;
  566. int j;
  567. char temp;
  568. i = 0;
  569. j = 0;
  570. while (str[i])
  571. {
  572. i++;
  573. }
  574. j = i - 1;
  575. i = 0;
  576. while (j > i)
  577. {
  578. temp = str[i];
  579. str[i] = str[j];
  580. str[j] = temp;
  581. i++;
  582. j--;
  583. //ft_putchar(i + 48);
  584. //ft_putchar(j + 48);
  585. //ft_putchar(temp);
  586. }
  587. return (str);
  588. }
  589.  
  590. int main()
  591. {
  592. char str[] = "defghj";
  593. printf("%s", ft_strrev(str));
  594. return (0);
  595. }
  596. e1r2p3% cat ft_putstr.c
  597. /* ************************************************************************** */
  598. /* */
  599. /* ::: :::::::: */
  600. /* ft_putstr.c :+: :+: :+: */
  601. /* +:+ +:+ +:+ */
  602. /* By: msabwat <marvin@42.fr> +#+ +:+ +#+ */
  603. /* +#+#+#+#+#+ +#+ */
  604. /* Created: 2017/08/08 19:43:42 by msabwat #+# #+# */
  605. /* Updated: 2017/08/08 20:48:39 by msabwat ### ########.fr */
  606. /* */
  607. /* ************************************************************************** */
  608.  
  609. void ft_putchar(char c);
  610.  
  611. void ft_putstr(char *str)
  612. {
  613. int i;
  614.  
  615. i = 0;
  616. while (str[i])
  617. {
  618. ft_putchar(str[i]);
  619. i++;
  620. }
  621.  
  622. }
  623. e1r2p3% vim ft_strrev.c
  624. e1r2p3% ls
  625. ft_strrev.c
  626. e1r2p3% cd ../ex08
  627. e1r2p3% ls
  628. e1r2p3% clear
  629.  
  630.  
  631.  
  632. /* ************************************************************************** */
  633. /* */
  634. /* ::: :::::::: */
  635. /* ft_atoi.c :+: :+: :+: */
  636. /* +:+ +:+ +:+ */
  637. /* By: msabwat <marvin@42.fr> +#+ +:+ +#+ */
  638. /* +#+#+#+#+#+ +#+ */
  639. /* Created: 2017/08/09 17:00:50 by msabwat #+# #+# */
  640. /* Updated: 2017/08/09 17:40:18 by msabwat ### ########.fr */
  641. /* */
  642. /* ************************************************************************** */
  643. #include <stdio.h>
  644. #include <unistd.h>
  645. #include <stdlib.h>
  646. int ft_putchar(char c)
  647. {
  648. write(1, &c,1);
  649. return (0);
  650. }
  651.  
  652. int ft_atoi(char *str)
  653. {
  654. int i;
  655.  
  656. i = 0;
  657. while (str[i])
  658. {
  659. ft_putchar(str[i]);
  660. i++;
  661. }
  662. return (0);
  663. }
  664.  
  665. int main()
  666. {
  667. printf("%d", atoi(" +65"));
  668. //printf("%d", ft_atoi(" +65"));
  669. ft_putchar('\n');
  670. printf("%d", atoi(" -986hgd69"));
  671. printf("%d", ft_atoi(" -986hgd69"));
  672. printf("%d", atoi("kjhcu54657c5465cds-+654"));
  673. printf("%d", ft_atoi("kjhcu54657c5465cds-+654"));
  674. printf("%d", atoi("32"));
  675. printf("%d", ft_atoi("32"));
  676. printf("%d", atoi("-457-24"));
  677. printf("%d", ft_atoi("-457-24"));
  678. return (0);
  679. }
  680. ~
  681. ~
  682. ~
  683. ~
  684. ~
  685. ~
  686. ~
  687. ~
  688. ~
  689. ~
  690. ~
  691. ~
  692. ~
  693. ~
  694. ~
  695. ~
  696. ~
  697. ~
  698. ~
  699. ~
  700. ~
  701. ~
  702. ft_atoi.c 48,2 All
  703. -- VISUAL -- 37
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement