עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

עזרה בהגדרת משתנה | שפת C

Featured Replies

פורסם


void main()
{

int constex;

printf("Enter a value of fixed expenses\n");
_flushall;
scanf("%d", &constex);
if ( )
printf("Input error!\n");
#include <stdio.h>

השאלה שלי היא איך אני מוציא/מדפיס הודעת שגיאה כאשר הקלט של המשתמש הוא אותיות במקום מספרים? הדרישה היא שהקלט של constex יהיה רק ספרות.

קו החשיבה שלי היה להוסיף משתנה כלשהו מסוג char נניח שאקרא לו ch ללא ערך מסויים, ולאמר ש if constex==ch

printf "INPUT ERROR"

זה לא עבד לי.

אח"כ ניסיתי להגדיר את ch בצורה הבאה ch>='A' && ch<='z'

ולאמר שאם constex=ch

printf INPUT ERROR

גם זה לא עבד.

רעיון? תודה.

נערך על-ידי Marksiman

פורסם

הפונקציה scanf מחזירה את מספר המשתנים שהיא קראה בהצלחה. כלומר אם הפונקציה הצליחה במקרה שלך אז היא תחזיר 1, ואם לא אז היא תחזיר 0.

שים לב שאם היא נכשלת אז קריאה נוספת ל-scanf תנסה לקרוא שוב את אותם התווים שהיא נכשלה בקריאה שלהם (כלומר היא לא מדלגת עליהם).

נערך על-ידי שניצל

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.