View Single Post
ישן 07-05-07, 14:00   # 1
mayden
Авторитет
 
מיני פרופיל
תאריך הצטרפות: Apr 2006
הודעות: 2,556

mayden לא מחובר  

[C] בעיה בתוכנית

יש לי את התוכנית הבאה:
קוד:
#include <stdio.h>
#include <string.h>

typedef char string;

void main () {
	string st1="ABCBD";
	string st2="CEB";
	string st3="";
	string sth="";
	int pl=0;
	char tav;
	while(strlen(st1)>0) {
		tav = st1[(strlen(st1)-1];
		strncpy(sth,st1,strlen(st)-1);
		if((strchr(st2,tav)!=null && (strchr(sth,tav) == null)
		{
			st3[pl] = tav;
			pl++;
		}
		strcpy(st1,sth);
	}
	st3[pl]='\0';
	puts(st3);

}
וכשאני מנסה להריץ אותה, כותב לי:
קוד:
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
C:\C\Cpp1.cpp(7) : error C2440: 'initializing' : cannot convert from 'char [6]' to 'char'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\C\Cpp1.cpp(8) : error C2440: 'initializing' : cannot convert from 'char [4]' to 'char'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\C\Cpp1.cpp(9) : error C2440: 'initializing' : cannot convert from 'char [1]' to 'char'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\C\Cpp1.cpp(10) : error C2440: 'initializing' : cannot convert from 'char [1]' to 'char'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\C\Cpp1.cpp(14) : error C2664: 'strlen' : cannot convert parameter 1 from 'char' to 'const char *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\C\Cpp1.cpp(14) : fatal error C1903: unable to recover from previous error(s); stopping compilation
אני משתמש בMicrosoft Visual C++

תודה.
__________________

ציטוט:
" זוכרים בשביל ללמוד, יודעים בשביל ללמד, מבינים בשביל לתכנת.."
  Reply With Quote