Skip to content
Snippets Groups Projects
Commit f9b86a45 authored by Mihail NECULA's avatar Mihail NECULA
Browse files

Add docs to functions + Handle unknown command + Repaired some problems from the old functions

parent 1b662c1a
No related branches found
No related tags found
No related merge requests found
Pipeline #98754 passed
This diff is collapsed.
// SPDX-License-Identifier: BSD-3-Clause
#include <sys/types.h>
#include <unistd.h>
#include "my_stdio.h"
int my_fwrite(const void *buff, size_t size, size_t nitems,int fd) {
int my_fwrite(const void *buff, size_t size, size_t nitems, int fd)
{
size_t total_bytes = size * nitems;
size_t total_writen_bytes = 0;
......@@ -17,4 +20,4 @@ int my_fwrite(const void *buff, size_t size, size_t nitems,int fd) {
}
return total_writen_bytes;
}
\ No newline at end of file
}
/* SPDX-License-Identifier: BSD-3-Clause */
#ifndef _MY_STDIO_H
#define _MY_STDIO_H
int my_fwrite(const void *buff, size_t size, size_t nitems,int fd);
int my_fwrite(const void *buff, size_t size, size_t nitems, int fd);
#endif /* _MY_STDIO_H */
\ No newline at end of file
#endif /* _MY_STDIO_H */
// SPDX-License-Identifier: BSD-3-Clause
#include <sys/types.h>
#include "my_string.h"
size_t my_strlen(const char *s) {
size_t my_strlen(const char *s)
{
if (!s)
return 0;
size_t cnt = 0;
while (s[cnt])
cnt++;
return cnt;
}
int my_strcmp(const char *s1, const char *s2) {
int my_strcmp(const char *s1, const char *s2)
{
size_t i;
for (i = 0; s1[i]; i++)
if (s1[i] != s2[i])
return s1[i] - s2[i];
return s1[i] - s2[i];
return s1[i] - s2[i];
}
void my_strcat(char *dst, const char *src) {
void my_strcat(char *dst, const char *src)
{
size_t i = 0;
while (dst[i])
i++;
size_t j = 0;
while (src[j]) {
dst[i + j] = src[j];
j++;
......@@ -30,7 +42,8 @@ void my_strcat(char *dst, const char *src) {
dst[i + j] = '\0';
}
void my_strcpy(char *dst, const char *src) {
void my_strcpy(char *dst, const char *src)
{
for (size_t i = 0; src[i]; ++i)
dst[i] = src[i];
}
\ No newline at end of file
}
/* SPDX-License-Identifier: BSD-3-Clause */
#ifndef _MY_STRING_H
#define _MY_STRING_H
......@@ -6,4 +8,4 @@ int my_strcmp(const char *s1, const char *s2);
void my_strcat(char *dst, const char *src);
void my_strcpy(char *dst, const char *src);
#endif /* _MY_STRING_H */
\ No newline at end of file
#endif /* _MY_STRING_H */
gcc: fatal error: no input files
compilation terminated.
mumu
mumu
beta
alfa
Linux
test
test
test
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment