Skip to content

Instantly share code, notes, and snippets.

@dlupaescu
Last active August 29, 2015 14:28
Show Gist options
  • Save dlupaescu/1d4ed737e70a44c262f9 to your computer and use it in GitHub Desktop.
Save dlupaescu/1d4ed737e70a44c262f9 to your computer and use it in GitHub Desktop.
Level: 0 | aff_last_param.c | only_a.c
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* aff_last_param.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: exam <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/08/21 17:04:17 by exam #+# #+# */
/* Updated: 2015/08/21 17:15:50 by exam ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
{
write(1, &str[i], 1);
i++;
}
write(1, "\n", 1);
}
int main(int argc, char **argv)
{
int i;
i = 1;
if (argc < 2)
{
write(1, "\n", 1);
return (0);
}
else
ft_putstr(argv[argc - 1]);
return (0);
}
/*
Exercitiu : aff_last_param
Fisiere de iesire : aff_last_param.c
Functii autorizate : write
--------------------------------------------------------------------------------
Scrieti un program ce ia ca parametru siruri de caractere si care afiseaza
ultimul parametru urmat de un '\n'.
Daca numarul de parametri este mai mic de 1, probramul afiseaza '\n'.
Example:
$> ./aff_last_param "zaz" "mange" "des" "chats" | cat -e
chats$
$> ./aff_last_param "j'aime le savon" | cat -e
j'aime le savon$
$> ./aff_last_param
$
*/
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* only_a.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: exam <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/08/21 17:02:35 by exam #+# #+# */
/* Updated: 2015/08/21 17:04:43 by exam ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
int main(void)
{
char c;
c = 'a';
write(1, &c, 1);
return (0);
}
/*
Assignment name : only_a
Expected files : only_a.c
Allowed functions: write
--------------------------------------------------------------------------------
Scrieti un program care afiseaza caracterul 'a' la iesirea standard.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment