Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

1.4 Έξοδος (Εκτύπωση Κειμένου) στην C

Για να εξάγετε τιμές ή να εκτυπώνετε κείμενο στη C, μπορείτε να χρησιμοποιήσετε τη συνάρτηση printf():

Σύνταξη:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
printf("text");
printf("text");
printf("text");

Το “text” μπορεί να είναι οποιοσδήποτε συνδυασμός χαρακτήρων, αριθμών και συμβόλων. Για παράδειγμα, η ακόλουθη εντολή εκτυπώνει το κείμενο “Hello, World!” στην οθόνη:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
printf("Hello, World!");
printf("Hello, World!");
printf("Hello, World!");

Εάν θέλετε να εκτυπώσετε μια μεταβλητή, μπορείτε να χρησιμοποιήσετε το %d (για ακέραιους αριθμούς), %f (για δεκαδικούς αριθμούς) και %s (για συμβολοσειρές) στη συνάρτηση printf():

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
int x = 5;
printf("The value of x is %d", x);
int x = 5; printf("The value of x is %d", x);
int x = 5;
printf("The value of x is %d", x);

Σε αυτό το παράδειγμα, η μεταβλητή x εκτυπώνεται μαζί με το κείμενο “The value of x is”. Το %d λέει στη συνάρτηση printf() να αντικαταστήσει τον κωδικό %d με την τιμή της μεταβλητής x.

Μπορείτε επίσης να χρησιμοποιήσετε διάφορα άλλα χαρακτηριστικά, όπως το %c για έναν χαρακτήρα, το %u για έναν ακέραιο αριθμό χωρίς πρόσημο, το %e για την επιστημονική αναπαράσταση δεκαδικών αριθμών, και πολλά άλλα.

Μπορείτε να χρησιμοποιήσετε όσες συναρτήσεις printf() θέλετε. Ωστόσο, να σημειώσετε ότι δεν εισάγει μια νέα γραμμή στο τέλος της έξοδου:

Για να προσθέσετε μια νέα γραμμή, μπορείτε να χρησιμοποιήσετε τη σειρά απόδρασης \n, ως εξής:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
printf("Hello, World!\n");
printf("Hello, World!\n");
printf("Hello, World!\n");

Στο παραπάνω παράδειγμα, το \n προσθέτει μια νέα γραμμή μετά την έξοδο του κειμένου “Hello, World!”.

Δωρεα μεσω Paypal

Για την κάλυψη αναγκών φιλοξενίας και δημιουργίας περιεχομένου.

κατηγοριες μαθηματων

Ιστορικο ενοτητων

top
error: Content is protected !!
Μετάβαση σε γραμμή εργαλείων