473,769 Members | 3,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Where's the mistake???

compiler says: function undeclared how come???
help!
#include<stdio. h>
#include<stdlib .h>
#include<time.h >

struct lista{
int element;
struct lista *next;
}*pocetak;

main()
{
struct lista *q, *nova;
int i;
pocetak=NULL;
srand(time(NULL ));
for(i=0;i<5;i++ )
{
q=(struct lista*) mallloc(sizeof( struct lista));
q->element=rand() %100;
pocetak=q;
q->next=NULL;
}
q=pocetak;
printf("Nasumic ni brojevi:\n");
while(q!=NULL)
{
printf("\n%d",q->element);
q=q->next;
}
printf("\nNaopa ko:\n");

return 0;
}
Nov 14 '05 #1
25 1529
Nikola <az*****@inet.h r> scribbled the following:
compiler says: function undeclared how come???
help!
#include<stdio. h>
#include<stdlib .h>
#include<time.h > q=(struct lista*) mallloc(sizeof( struct lista));


You'll want to have a second look at this line here.

(Besides, you don't need the cast.)

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"War! Huh! Good God, y'all! What is it good for? We asked Mayor Quimby."
- Kent Brockman
Nov 14 '05 #2
Nikola wrote:
compiler says: function undeclared how come???
You ask a simple/silly question and don't even supply
us what funtion the compiler complains about. Be more
specific next time.
help!
#include<stdio. h>
#include<stdlib .h>
#include<time.h >

struct lista{
int element;
struct lista *next;
}*pocetak;

main()
{
struct lista *q, *nova;
int i;
pocetak=NULL;
srand(time(NULL ));
for(i=0;i<5;i++ )
{
q=(struct lista*) mallloc(sizeof( struct lista));
mallloc() -> malloc()
q->element=rand() %100;
pocetak=q;
q->next=NULL;
}
q=pocetak;
printf("Nasumic ni brojevi:\n");
while(q!=NULL)
{
printf("\n%d",q->element);
q=q->next;
}
printf("\nNaopa ko:\n");

return 0;
}


Nov 14 '05 #3
Joona I Palaste <pa*****@cc.hel sinki.fi> spoke thus:
q=(struct lista*) mallloc(sizeof( struct lista));
You'll want to have a second look at this line here.


Heh, been there, done that several times myself, unfortunately.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #4
here's the full code :

#include<stdio. h>
#include<stdlib .h>
#include<time.h >

struct lista{
int element;
struct lista *next;
}*pocetak;

main()
{
struct lista *q, *nova;
int i;
pocetak=NULL;
srand(time(NULL ));
for(i=0;i<5;i++ )
{
q=(struct lista*) mallloc(sizeof( struct lista));
q->element=rand() %100;
pocetak=q;
q->next=NULL;
}
q=pocetak;
printf("Random numbers:\n");
while(q!=NULL)
{
printf("\n%d",q->element);
q=q->next;
}

q=pocetak;
for(i=0;i<5;i++ )
{
nova=(struct lista*) mallloc(sizeof( struct lista));
nova->element=*(poce tak+(5-i)*(sizeof(stru ct lista)));
pocetak=nova;
nova->next=NULL;
}
nova=pocetak;
printf("\nOther way round:\n");
while(nova!=NUL L)
{
printf("\n%d",n ova->element);
nova=nova->next;
}
system("pause") ;
return 0;
}
Nov 14 '05 #5
I took a wild shot guessing dtat you have a compiler :-)
Nov 14 '05 #6
Nikola <az*****@inet.h r> scribbled the following:
here's the full code : #include<stdio. h>
#include<stdlib .h>
#include<time.h >
(snip)
q=(struct lista*) mallloc(sizeof( struct lista));
(snip)
nova=(struct lista*) mallloc(sizeof( struct lista));


It's even consistent and everything. Do you have a C textbook? If so,
please re-read the chapter about memory alllocation, sorry, I mean
allocation.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"The large yellow ships hung in the sky in exactly the same way that bricks
don't."
- Douglas Adams
Nov 14 '05 #7
Nikola wrote:
I took a wild shot guessing dtat you have a compiler :-)


It takes me time to copy-paste-compile. You're the one
that's asking for help. Be kind to the people you ask
help from and let me decide how to help you.

All the best,

Case

Nov 14 '05 #8
Joona I Palaste wrote:
Nikola <az*****@inet.h r> scribbled the following:
here's the full code :


#include<stdi o.h>
#include<stdl ib.h>
#include<time .h>

(snip)

q=(struct lista*) mallloc(sizeof( struct lista));

(snip)

nova=(struct lista*) mallloc(sizeof( struct lista));

It's even consistent and everything. Do you have a C textbook? If so,
please re-read the chapter about memory alllocation, sorry, I mean
allocation.


You made me laugh. Thanks!

Case

Nov 14 '05 #9
Christopher Benson-Manica <at***@nospam.c yberspace.org> writes:
Joona I Palaste <pa*****@cc.hel sinki.fi> spoke thus:
q=(struct lista*) mallloc(sizeof( struct lista));

You'll want to have a second look at this line here.


Heh, been there, done that several times myself, unfortunately.


Don't you enable suitable warnings? This class of mistake should
be pointed out by the compiler. But even if not, then the linker
message should make the error obvious.
--
Ben Pfaff
email: bl*@cs.stanford .edu
web: http://benpfaff.org
Nov 14 '05 #10

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

Similar topics

3
1732
by: Paul T. Rong | last post by:
Dear all, My aim is to compact and repair current database, I got the following code from http://www.mvps.org/access/general/gen0041.htm Option Compare Database ' ***** Code Start ***** Public Sub CompactDB()
15
2252
by: Paul T. RONG | last post by:
Hello, I am making a restaurant database (it is much more complicated than I thought before!), now it comes to the last stage and I come across a problem. I will explain it in detail. In a restaurant, though rarely, but it happens, that one guy from desk1 would like to pay for bills of both desk1 and desk2 (I avoid using Access term "table"), that means the dishes that ordered seperately before by desk1 and desk2 now have to be commixed...
23
1785
by: Red Dragon | last post by:
I am self study C program student. Hope someone can help me with this problem. This program generates random numbers over a user defined range using call function I used the call function " GenRndNum". The range is 2 and 10. The problem is that I get the same 2 random numbers generated over 2 calls. I should get 2 different random numbers. Can someone please point out my mistake? Thanks Khoon.
3
14939
by: bughunter | last post by:
IMHO, statements like this is mistake typically. May be more better made this construction - I said about empty WHERE - invalid? A lot of data will saved... :-) Andy
2
1150
by: Lad | last post by:
I use the following code to sort dictionary. Olddict={'r':4,'c':1,'d':2,'e':3,'f':2} Newdict={} i = i.sort() # by val i.reverse() # Get largest first. for (val, key) in i: print key,val
20
5245
by: Frank-O | last post by:
Hi , Recently I have been commited to the task of "translating" some complex statistical algorithms from Matlab to C++. The goal is to be three times as fast as matlab ( the latest) . I've used various techniques ( loop unrolling, loop jamming...) and tried some matrix libraries : newmat (slow for large matrix) , STL (fast but ..not usefull) , hand coding (brain consuming...), and recently Meschach...
4
2184
by: Winston | last post by:
Where is the mistake? I want to make a simple menu. These are two pieces of two files... function ShowMenu(objeto) { is_open = document.getElementById(objeto).style.display; document.getElementById("menu_p").style.display='none'; if (is_open == 'none') { document.getElementById(objeto).style.display='block'; }
4
3570
by: | last post by:
I have learned about compartmentalizing my code base using Class Libraries. I have my common code such as my ORM framework broken out into their own Class Libraries, which are referenced as projects from my Website. I also have a common set of DLLs I use across all of my applications. It would be great if I could put all of those DLLs into their own projects, and to reference that project from various solutions. The way my solution is...
2
1217
by: Eglute | last post by:
Hello. I have a problem. I am a begginer in PHP. I wrote the code: <? $variable=5; $variable<10? {$ans="less"; echo $ans."<br>"; echo "variable=".$variable."<br>";}: {$ans="more"; echo $ans."<br>"; echo "variable =".$variable."<br>";} ?>
0
9422
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10035
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.