Hello.
I am indeed trying to write a C program not a C++ program. But after reading that paper; the link of which you provided in your reply,I am rather impressed by the ease of using C++ vis-a-vis C.
My objective isto get a fair grasp over C before plunging into C++.
Hence I don't mind doing some extra work in C. hehehe
How else will I realise the ease of using C++. Anyway, sorry for going off track. Heres my code , if you could till suggest a better alternative then please do let me know:
Code:#include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> int main() { char *string1; printf("enter string1\n"); string1 = (char *) malloc (500); fgets(string1,500,stdin); if (string1[strlen(string1)-1] == '\n') string1[strlen(string1)-1] = '\0'; printf("\nstring1 has %d characters\n",strlen(string1)); printf("string = %s\n",string1); free(string1); return 0; }




Reply With Quote