Click to See Complete Forum and Search --> : C, C+, C++, C#


elwell
08-10-2003, 08:58 PM
What are the differences between C, C+, C++, and C#?
Can you use a C compiler for C+, C++ and/or C#?


And also:
I wrote my first C executable file today and a made another one that doesn't seem to work quite right. I wan to type five characters then six characters in another input then write it out diagnally but the ch11 (the last character) always gets cut off. Can someone tell me what I did wrong.



int main()
{
int ch, ch2, ch3, ch4, ch5, ch6, ch7, ch8, ch9, ch10, ch11;

printf ("Please type in five characters of your first name:\n");
ch = getc( stdin );
ch2 = getchar();
ch3 = getc( stdin );
ch4 = getchar();
ch5 = getc( stdin );
printf ("Please type in six characters of your last name:\n");
ch6 = getc( stdin );
ch7 = getchar();
ch8 = getc( stdin );
ch9 = getchar();
ch10 = getc( stdin );
ch11 = getchar();
printf("%2c\n", ch);
printf("%3c\n", ch2);
printf("%4c\n", ch3);
printf("%5c\n", ch4);
printf("%6c\n", ch5);
printf("%2c\n", ch6);
printf("%3c\n", ch7);
printf("%4c\n", ch8);
printf("%5c\n", ch9);
printf("%6c\n", ch10);
printf("%7c\n", ch11);

return 0;
}

Jeff Mott
08-10-2003, 10:55 PM
What are the differences between C, C+, C++, and C#?C is a popular programming language used for everything from microcontrollers to operating systems to the most advanced scientific systems. C++ is an extension of C, incorporating object-oriented capabilities. (There is no C+ language.) C# is part of Microsoft's .NET platform, meant to improve on Java and C++. I wan to type five characters then six characters in another input then write it out diagnally but the ch11 (the last character) always gets cut off. Can someone tell me what I did wrong.The character being reach into ch6 is the newline from pressing enter. A couple other notes: why do you keep switching between getc and getchar? Also, a series of variables indexed by a number (such as ch3, ch4, ch5, etc.) is the job for an array. There is also a char data type. Defining a variable meant for a character as an integer is a waste of memory. You also have to consider what should happen if the user types in more or less than the number of characters you were expecting (e.g., my last name is only four characters long).

Charles
08-11-2003, 06:44 AM
And there is no C+ for a good reason. The name C++ is a joke. The next version will have to be called C += 2.

elwell
08-11-2003, 11:33 AM
I just started learning C yesterday so I don't know how to do Array yet in C. My book "Sams Teach Yourself C in 24 hours" showed both getc and getchar in one script for the user to type in two characters. That was the script I wrote first so when I wanted to have more characters be entered I just copied and pasted both of those together and changed the "ch" number. In other word I knew it didn't matter which one I used so I did the easiest way.

Jona
08-12-2003, 11:49 AM
Originally posted by Charles
And there is no C+ for a good reason. The name C++ is a joke. The next version will have to be called C += 2.

Ha ha! Good one, Charles! :D

[J]ona