CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

CCS'DE STRUCT KULLANIMI

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ismail66c



Joined: 09 Nov 2008
Posts: 6

View user's profile Send private message

CCS'DE STRUCT KULLANIMI
PostPosted: Sun Nov 09, 2008 1:50 pm     Reply with quote

struct kulanımında hatalarla karşılaşmaktayım, aşagıda bunu açıklıyorum yardımcı olan olursa sevinirim.

struct veri {
char *ad;
int no;
}
struct veri kayit[5];
yukarıda yazılı tanımlamalar main dosyası içerisinde tanımlanamamaktadır,sorunun biri bu. Bu tanımlama main dosyasıo dışında tanımlanıp kayit[0].ad="mehmet" ataması yaptıgımda buişlem gerçeleşmemektedir, ama char oku[]="mehmet" ataması yapıp sonra
kayit[0].ad=oku işlemi dogru olarak çalışmaktadır, buradaki sorunu çözmeye çalışıyorum yardımcı olan olursa sevinirim.
ismail66c



Joined: 09 Nov 2008
Posts: 6

View user's profile Send private message

Re: CCS'DE STRUCT KULLANIMI
PostPosted: Sun Nov 09, 2008 1:53 pm     Reply with quote

ismail66c wrote:
struct kulanımında hatalarla karşılaşmaktayım, aşagıda bunu açıklıyorum yardımcı olan olursa sevinirim.

struct veri {
char *ad;
int no;
};
struct veri kayit[5];
yukarıda yazılı tanımlamalar main dosyası içerisinde tanımlanamamaktadır,sorunun biri bu. Bu tanımlama main dosyası dışında tanımlanıp kayit[0].ad="mehmet" ataması yaptıgımda buişlem gerçekleşmemektedir, ama char oku[]="mehmet" ataması yapıp sonra
kayit[0].ad=oku işlemi dogru olarak çalışmaktadır, buradaki sorunu çözmeye çalışıyorum yardımcı olan olursa sevinirim.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Nov 09, 2008 1:53 pm     Reply with quote

And in English this is .... ??
ismail66c



Joined: 09 Nov 2008
Posts: 6

View user's profile Send private message

Re: CCS'DE STRUCT KULLANIMI
PostPosted: Sun Nov 09, 2008 2:00 pm     Reply with quote

struct use
Code:

struct veri {
char *ad;
int no;
};

struct veri kayit[5];

This is not working in main file.The other problem kayit[0].ad="mehmet" not working, but char oku[]="mehmet" and then
kayit[0].ad=oku is working, where I make mistake ?
Ttelmah
Guest







PostPosted: Sun Nov 09, 2008 2:31 pm     Reply with quote

The reason this assignment won't work, is that in CCS, by default, you cannot have pointers to constants. This is in the manual.
The point is that the PIC, has an architecture, where code, and RAM memory spaces are separate. Constants, by default, are in the code space, not the RAM space, and cannot therefore be accessed via a RAM pointer. You need to allocate RAM, and copy the constants to RAM, which is what your 'char' declaration version does.
On the late compilers (last few versions), you can use a ROM declaration, rather than a const declaration (or set the compiler options default to this), _but_ at a cost in terms of code size, and the pointer needs to be a ROM pointer, not a RAM pointer.
There is no reason for it not working in main. You don't show enough to guess what is wrong with this.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group