473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

About Assignment

Hi to all,

I have this declaration:

struct node
{
char info[BUFLEN] ;
struct node *next ;
} ;


and in the main

char msg[BUFLEN];

After the initialition of string with (for example)

i=0;
char_recv = recv(newsocketfd, &c, 1, 0);
while (c !='\n')
{
msg[i++]=c;
char_recv = recv(newsocketfd, &c, 1, 0);
} /* End while (c !='\n') */


I need to insert msg into my list; if I write
p = malloc(sizeof(struct node));
p->info = msg;
p->next = first;
first = p;


the compiler return to me the message:
error: incompatible type in assignement

How can to correct the error ? I hope in Your help.

Best Regards
Gaetano

Apr 7 '07 #1
2 1213
On 4月7日, 下午1时34分, "nick048" <nicosia.gaet...@moonsoft.itwrote:
Hi to all,

I have this declaration:

struct node
{
char info[BUFLEN] ;
struct node *next ;

} ;


and in the main

char msg[BUFLEN];

After the initialition of string with (for example)

i=0;
char_recv = recv(newsocketfd, &c, 1, 0);
while (c !='\n')
{
msg[i++]=c;
char_recv = recv(newsocketfd, &c, 1, 0);

} /* End while (c !='\n') */


I need to insert msg into my list; if I write
[i]p = malloc(sizeof(struct node));
Check whether 'p' is NULL, please.
p->info = msg;
You really want "strcpy(p->info, msg);", right?


Apr 7 '07 #2
On 7 Apr, 08:09, "Cong Wang" <xiyou.wangc...@gmail.comwrote:
On 4鏈7鏃, 涓嬪崍1鏃34鍒, "nick048" <nicosia.gaet...@moonsoft.itwrote:


Hi to all,
I have this declaration:
struct node
{
* * char info[BUFLEN] ;
* * struct node *next ;

} ;
>
and in the main
char msg[BUFLEN];
After the initialition of string with (for example)
i=0;
char_recv = recv(newsocketfd, &c, 1, 0);
while (c !='\n')
{
* msg[i++]=c;
* char_recv = recv(newsocketfd, &c, 1, 0);

} /* End while (c !='\n') */
>
I need to insert msg into my list; if I write
[i]p = malloc(sizeof(struct node));

Check whether 'p' is NULL, please.
* *p->info = msg;

You really want "strcpy(p->info, msg);", right?- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -
Yes,
I have tried the assignment with strcpy() and all work fine.
Thank You

Apr 7 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
5
by: Haoyu Zhang | last post by:
Dear Friends, Python assignment is a reference assignment. However, I really can't explain the difference in the following example. When the object is a list, the assignment seems to be a...
7
by: Snake | last post by:
Hi guys, I have question about classes. when u create class called Test. and you define variable Test c; so does this act like( a variable c of type Test pointing to an abject )? The thing that...
14
by: Fred H | last post by:
I'm reading a STL book right now, and there I've picked up the folowing syntax: class C { private: int value; public: C(int initValue) : value(initValue) { } }
2
by: Abubakar | last post by:
Hi all, The variables declared inside try block cant be accessed inside its corresponding finally block. When I used to explain finally concept to anyone I would usually tell them (briefly) that...
28
by: WaterWalk | last post by:
Hi, I'm haunted by 2 questions about struct copy. Though I searched the net, but still in confusion. 1. Does struct assignment copies every member including array members? For example, struct...
19
by: fyhuang | last post by:
Hello all, I've been wondering a lot about why Python handles classes and OOP the way it does. From what I understand, there is no concept of class encapsulation in Python, i.e. no such thing as...
56
by: spibou | last post by:
In the statement "a *= expression" is expression assumed to be parenthesized ? For example if I write "a *= b+c" is this the same as "a = a * (b+c)" or "a = a * b+c" ?
37
by: Hilton | last post by:
Hi, for (int i = 0; i < list.Count; i++) has a hidden performance hit; i.e. list.Count gets evaluated each time, so we write something like: int listCount = list.Count; for (int i = 0; i <...
1
by: khalfan | last post by:
Assignment Objectives: The objective of this assignment is to design and develop a dynamic web site application with the use of ASP to create a database and manipulate the information. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.