File tree 3 files changed +41
-0
lines changed
0x05-pointers_arrays_strings
3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+ #include <stdio.h>
3
+
4
+ /**
5
+ * main - check the code
6
+ *
7
+ * Return: Always 0.
8
+ */
9
+ int main (void )
10
+ {
11
+ char * str ;
12
+ int len ;
13
+
14
+ str = "My first strlen!" ;
15
+ len = _strlen (str );
16
+ printf ("%d\n" , len );
17
+ return (0 );
18
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+
3
+ /**
4
+ * _strlen - return the length of a string.
5
+ *
6
+ * @s: string.
7
+ *
8
+ * Return: length of the string.
9
+ */
10
+ int _strlen (char * s )
11
+ {
12
+ char * ptr ;
13
+ int size = 0 ;
14
+
15
+ ptr = s ;
16
+ while (* ptr != '\0' )
17
+ {
18
+ size = sizeof (* ptr ) + size ;
19
+ ptr = ptr + 1 ;
20
+ }
21
+ return (size );
22
+ }
Original file line number Diff line number Diff line change 1
1
int _putchar (char );
2
2
void reset_to_98 (int * );
3
3
void swap_int (int * , int * );
4
+ int _strlen (char * );
You can’t perform that action at this time.
0 commit comments