السلام عليكم ,,
ارجوا مساعدتي في هذا الكود ,,
انا اجبت على فكرة البرنامج,,لكن طلبات السؤال في ترتيب البرنامج لم استطع حلها,,
استطيع وضع functhin ,, ولكن لدي مشكلة في pointer ,, فهمته بشكل عام..لكن يدخل في برنامج مثل هذا ..
للاسف مافهمت فكرته ..!!
ارجوا مساعدتي وجزاكم الله كل خير ..
Write a program that reads from the user two words (as array of characters) the program
then copies the shortest word into an array and prints the word to the user along with number of
characters in the word.
Your program should include:
Three character arrays and a pointer to each array
Function readArray which takes a pointer to an array of characters and asks the user to input
a word
Function findShortest which receives pointers to the two words, compares between them
and prints the shortest one along with the number of characters.
هذا الكود بدون الدخول في طلبات السؤال :
#include <iostream>
using namespace std;
void main()
{
char x[30]; char *x;
char y[30]; char *y;
char z[30]; char *z;
int countX=0,countY=0;
cout<<"enter first word"<<endl;
cin>>x;
cout<<"enter scound word"<<endl;
cin>>y;
for(int i=0;x!='\0';i++)
countX+=1;
for(int j=0;y[j]!='\0';j++)
countY+=1;
if(countX<countY)
cout<<"the shortest word is "<<x<<" with "<<countX<<" character";
else
cout<<"the shortest word is "<<y<<"with "<<countY<<"character";
}