السلام عليكم
معليش بعد إذن الاخت "smile" :)
لما جربت برنامج فصل الكلمات ما اشتغل وكان في غلط
انه يحذف اول حرف من كل كلمة
وحاولت اعدل فيه والحمدلله اشتغل مزبوط بعد تعديل بسيط=)
اول حاجه في التعريفات لازم تحطي التعريف دا مع الفنكشنز الجاهزة تبعت الstring
كود PHP:
#include<string.h>
, بس غيرت الشرط التاني اللي هوا دا>>
كود PHP:
while(str[i]==' ')
وهذا الكود بعد التعديل
كود PHP:
#include<conio.h>
#include<stdio.h>
#include<string.h>
void remove(char str[]);
void main()
{
char str[80];
gets(str);
remove(str);
getch();
}
//-----------------------------------
void remove(char str[])
{
char temp[20],nn[20];
int t=0, n=0;
int l=strlen(str);
for(int i=0;i<=l;i++)
{
if((str[i]!=' ')&&(str[i]!='\0'))
{
temp[t++]=str[i];
nn[n++]=str[i];
}
else
{
if((str[i]==' ')||(str[i]=='\0'))
temp[t]='\0';
printf("%s",temp);
printf("\n");
t=0;
nn[n++]=' ';
}
}
nn[n]='\0';
printf("%s",nn);
}
بالتوفيق =)