I'm just starting to learn C and the first exercise made in class was to make a program that prints the sum of two integers.
This program:
#include <stdio.h>
#include <stdlib.h>
int main (void) {
int n1,n2;
printf("1st int: ");
scanf("%d",&n1);
printf("2nd int: ");
scanf("%d",&n2);
printf("Sum = %d\n",n1+n2);
return EXIT_SUCCESS;
}
I showed it to some of my older classmates and went batshit insane with it saying: DO NOT USE PRINTF AND SCANF, THEY ARE NOT FUCKING SAME and other stuff.
Will someone please input on this matter?
Thank you!
printf is fine, tell your friends to stop being idiots. scanf isn't unsafe (as long as you wrap it in some error recovery code), but it's basically worthless for actual input. Use readline or fgets, then sscanf the result or parse it yourself.
besides string handling in C is generaly shit ,
Is that your way of saying "I don't understand programming"?
Name:
Anonymous2009-10-20 8:00
>>29
String handling in C is like using club as a weapon. Its not that effective, but you can upgrade it or sharpen it with tools. It will remain a club though, while your neighbors sport Ak-47 and uzi's.
However when civilization is done, the resources are scarce and there is nothing much left, the club is best tool for the job.
Name:
Anonymous2009-10-20 8:03
>>29
As someone who loves C, I've got to say that string handling in C is painful at best.
However, that doesn't stop me from doing stupid things like trying to write a regex engine in it.
Name:
Anonymous2009-10-20 8:10
>>31
It would be much improved if C had length-prefixed strings
Im looking for a print function, it cant be printufu (thats japanese for printf) or any stdio function. It has to be of 2 or more parameteru (thats japanese for 2 parameters) and has be be chibi (small) sized. And has to be really kawaii (cute). Also It has to be about 10-20 bux. And you have to post documentation of it first (i want to make shure it's kawaii [cute]). And it would be nice if it came with matching input reading (WITH error handling). OH! and it CANNOT have any complicated syntax, or be made out of C. It has to be made of C++, or something like that. Also it would be nice if it was made in japan. and not in china or corea (korea) or whatever. I have found a function similar to the one im describing in sourceforge, but it was 1 parameteru, and i dont want my formatou (formatting) to touch my other things (it can get mixed up and i would not like that, plus 2 paraneters looks more kawaii)
Name:
Anonymous2009-10-20 9:09
>>37
KOREA HAS THE BEST PROGRAMMERS.
Why would you want Japanese pigdogs to do it?
Damn stupid weeaboos! Koreaboos are much smarter and better looking!!!!!
Name:
Anonymous2009-10-20 9:19
>>35
Admit it, the length prefix was cumbersome only in days where every byte was counted. Today, RAM is especially cheap.
>>68
It works inside a -E at least. If you're actually running it as a file you need a version declaration. :(
Or you could do it the old way:print<>+<>,"\n" >>69
No, lern2perl.
C:\Users\haskal\Documents\Downloads\qbasic\qbasic.exe
This version of C:\Users\haskal\Documents\Downloads\qbasic\qbasic.exe is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.
Windows doesn't even know what architecture it's running on!