برنامه ای در ++C که تابع strcat را شبیه سازی کند [آرشيو] - P30World Forums

PDA

View Full Version : برنامه ای در ++C که تابع strcat را شبیه سازی کند


بنفشه
12-20-2005, 01:22 PM
برنامه ای در ++C که تابع strcat را شبیه سازی کند(الحاق دو رشته با پارامتر n )
از لطفتان ممنون میشوم.

bithiah
12-20-2005, 02:21 PM
بنفشه جان
تا جایی که بخاطر میارم تابع strcat کارش این بود که دو رشته رو بهم متصل می کرد. نوشتن کد برای این کار نباید خیلی دشوار باشه، با وجود این با عرض معذرت چون خیلی وقته بزبون C برنامه ننوشتم، نمی تونم خودم براتون بنویسمش. ولی ببینین آیا با کمک این کد به جواب سوالتون می رسین:
!!!! برای مشاهده محتوا ، لطفا ثبت نام کنید / وارد شوید !!!!
این نمونه کد رو هم ببینین:
http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=3775&lngWId=3
موفق باشید

بنفشه
12-25-2005, 09:36 PM
متاسفانه موفق نشدم ولي از لطف و توجهتان ممنونم.

someone
08-04-2006, 05:42 PM
you use from system("pause"); this function define in" Windows.h"
you must use this header.
if you want this program yet tell me please.

lord fogir
08-20-2006, 03:28 AM
#include <iostream.h>

void strcat(char *,char *,int);
int main()
{
char s1[20],s2[20];
int n;
cout<<"Enter string 1:"<<endl;
cin>>s1;
cout<<"Enter string 2:"<<endl;
cin>>s2;
cout<<"Enter number:"<<endl;
cin>>n;
strcat(s1," ",n);
strcat(s1,s2,n);
cout<<s1;
return 0;
}
void strcat(char *s1,char *s2,int n)
{
int i=0;
while(*s1++);
*s1--;
while(*s2 && i<n)
{
*s1++=*s2++;
i++;
}
*s1='\0';
}

soheil1366
08-22-2006, 10:26 PM
برنامه ای در ++C که تابع strcat را شبیه سازی کند(الحاق دو رشته با پارامتر n )
از لطفتان ممنون میشوم.
اينم strcat :
#include<iostream>
#include<conio.h>
using namespace std;
void concat(char[],char[]);
int main()
{
char a[21],b[41];
cout<<"Enter first string:";
cin.getline(b,40);
cout<<"\nEnter second sting:";
cin.getline(a,40);
concat(a,b);
getch();
return 0;
}
void concat(char a[21],char b[40])
{
int i,j;
for(i=0;b[i];i++);
for(j=0;a[j];j++)
b[i++]=a[j];
b[i]=0;
cout<<b;
}