Sorry for all the posts but...
Well thanks guys for the good tutorial i created my first program written with the basic knowledge of C but some bugs need to be worked out.
Well heres my Program code:
Code:
#include <stdio.h>
#include <string.h>
void strip_newline( char *str, int size )
{
int i;
for ( i = 0; 1 < size; ++i )
{
if ( str[i] == '\n' )
{
str[i] = '\0';
}
return;
}
}
int main()
{
FILE* Testfile;
FILE *fp;
char name[50];
char lastname[50];
char fullname[100];
printf( " Please enter your first name name: " );
fgets( name, 50, stdin );
strip_newline( name, 50 );
if ( strcmp ( name, "Alex" ) == 0 )
{
printf( "thats my name too.\n" );
}
else
{
printf( "Thats not my name :(\n" );
}
printf( "Your name is %d, letters long", strlen ( name ) );
printf( "Enter Your Last Name: " );
fgets( lastname, 50, stdin );
strip_newline( lastname, 50 );
fullname[0] = '\0';
strcat( fullname, name );
strcat( fullname, " " );
strcat( fullname, lastname );
fp=fopen("C:\\Test.txt", "w");
fprintf(fp, "First Name: %s", fullname );
printf( "Your full name is %s\n",fullname );
getchar();
return 0;
}
I Combined the tutorials Code with the File input output protocol. Just need to get it to add the last name along with the first name
P.S If your gonna try it it creates a file in you c drive named Test.txt Which has ur name.
Thanks for the tutorial.