commit
This commit is contained in:
37
C_02/git/ex01/main.c
Normal file
37
C_02/git/ex01/main.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* main.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/09 18:18:58 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/11 18:07:07 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char *ft_strncpy(char *dest, char *src, unsigned int n);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char src[32];
|
||||
char dest[64];
|
||||
unsigned int n;
|
||||
char *result;
|
||||
|
||||
n = 0;
|
||||
printf("Input String [max 31]: ");
|
||||
scanf("%s", src);
|
||||
printf("Input Size: ");
|
||||
scanf("%d", &n);
|
||||
result = ft_strncpy(dest, src, n);
|
||||
printf("src=%s dest=%s n=%d result=%s (ft_strncpy)\n", src, dest, n, result);
|
||||
result = strncpy(dest, src, n);
|
||||
printf("src=%s dest=%s n=%d result=%s (strncpy)\n", src, dest, n, result);
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user