עבור לתוכן
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/c++ תרגול קוד יעיל

Featured Replies

פורסם
  • מחבר

פיתאום זה עובד גם עם ה int :)

************************

מחרוזות

(שאלה פשוטה)

קלוט שם ושם מישפחה וצור מחרוזת נוספת המכילה שם פרטי ושם מישפחה.

 #include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <string.h>


int main()
{
int name[20],last_name[20],total[50];
printf ("enter your name!");
gets(name);
printf ("enter your last name!");
gets(last_name);
strcpy(total,name);
strcat(total, " ");
strcat(total,last_name);
puts (total);


getch();

return 0;

}

  • תגובות 96
  • צפיות 8.6k
  • נוצר
  • תגובה אחרונה
פורסם
  • מחבר

---עוד שאלה קלילה----

קלוט מחרוזת והדפס את אורכה.

  #include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <string.h>


int main()

{
char word[100];
int str;
printf ("enter a word!(up to 50 letters) :");
gets(word);
str=strlen (word);
printf(" the len of the `word` %d\n ",str);


getch();

return 0;


}

פורסם

אתה חייב לבחור שמות משמעותיים יותר.

המשתנה str יכול להיקרא strLength או רק length.

אגב, אם כבר ++C אז תשתמש ב-()cin.get ולא ב-()getch

פורסם
  • מחבר

:xyxthumbs:

עברתי ל c (אני מקודד עכשיו ב C).

פורסם

cin.get זה לא אותו דבר כמו getch... הראשון קורא תו מהbuffer והשני קורא ישירות מהמקלדת.

פורסם
  • מחבר

קלוט שני מחרוזות ובדוק אם הם זהות.

  #include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>


int main()
{
char name[50],name_2[50];
int calculus_cmp=0;
printf ("enter your name!(up to 40 letters)");
gets (name);
printf("enter another name!(up to 40 letters)");
gets (name_2);
calculus_cmp= strcmp(name,name_2);
if (calculus_cmp == 0){
printf("the names are the same!");
}
else
printf("the names are not the same!");





getch();

return 0;

}

פורסם

למה לשמור את הערך שמחזירה הפונקציה strcmp ולא ישר לבצע בדיקה עליו? לדוגמא:


if (strcmp(name1,name2))
{
printf("the names are different");
}
else
{
printf("the names are identical");
}

ארכיון

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

דיונים חדשים

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.