IHYPRESS.NET
C
HOME | ASP | C | CSS | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
Earn Free Bitcoin
CStrings ❯ Reading with scanf
<08.01>
/* Reading a string with scanf */
#include <stdio.h> #include <string.h> int main (void) { char city[20], city2[20]; printf ("What is the capital of Canada? "); /* the string is read with the %s placeholder */ /* do not use & or use &city[0] */ scanf ("%s", city); printf ("What is the capital of Argentina? "); scanf ("%s", city2); /* here is the report */ printf ("\nThe capital of Canada is: %s.", city); printf ("\nThe capital of Argentina is: %s.", city2); return (0); }
Hergestellt in Deutschland / Made in Germany
What is the capital of Canada? Ottawa What is the capital of Argentina? Buenos Aires The capital of Canada is: Ottawa. The capital of Argentina is: Buenos.
COPYRIGHT © 2015-2024 IHYPRESS.NET. A DIVISION OF IHY PRESS. ALL RIGHTS RESERVED.