By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,364 Members | 1,652 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,364 IT Pros & Developers. It's quick & easy.

Error of : initialization makes pointer from integer without a cast

P: 6
Hi there, im pretty new to this forum and would be grateful of some help. I've only started programming this year and am pretty lazy with it so please bare with me if im acting like a bit of a noob...

right basically im trying to define a struct that will hold names for a phonebook i.e. with a string and a number

i have #included<stdlib.h> and everything else I need, and the 2 parts im struggling with are as follows

typedef struct {char name[20]; int num;} Phnbk;

Phnbk makeBook(char name[20], int num){
Phnbk entry = {name, num};
return entry;
}

from what I can see everything is in order, but when I compile I get an error saying:
In function makeBook:
warning: initialization makes pointer from integer without a cast

the rest of the code is fine in the program and compiles and runs perfectly when the above lines are commented out...

Any suggestions?

Cheers, Dan
Sep 1 '07 #1
Share this Question
Share on Google+
1 Reply


P: 6
Hi all, sorted it, I did try making the name a pointer i.e. entry = {*name.. but i clearly didnt save before re compiling and trying all sorts of other rubbish...such a noob...oh well thanks anyways!
Sep 1 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.