Hi,
I am writing custom gets() and puts() functions. I have started like this but got stuck as i didnt know to store the char.... I think the code will tell you where i am stuck
Code:
#include <stdio.h>
#include <string.h>
void xgets(char *str);
char str1[100];
int main()
{
char str[100];
printf("Enter a string");
xgets(str);
printf("%s",str);
return 0;
}
void xgets(char *str)
{
while(*str!='\n')
{
well that was for gets
and this is for puts
Code:
#include <stdio.h>
#include <string.h>
void xputs(char *str);
int main()
{
char str[100];
printf("Enter a string");
gets(str);
xputs(str);
return 0;
}
void xputs(char *str)
{
while(*str!='\0')
{
printf("%c",*str);
str++;
}
}
this one works if a string is passed to puts. But if puts is like this then i dont know how to get it working.
puts("Print this");
Hope i am clear with my question.
Please help.