To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 3744
3743  |  3745
Subject: 
Re: problems with creating arrays of larger sizes
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Mon, 17 May 2004 14:47:13 GMT
Viewed: 
4999 times
  
Andreas Jurk wrote:
OK, here is my code.

int main()
{
int i;
char c[n];

for(i=0;i<n;i++)
{
*(c+i)=0;
}
return 0;
}

This won't work for sure. If you look into the kernel sources,
DEFAULT_STACK_SIZE gives the value for every user program's stack.
Actually, this is 1KByte, if I remeber it right. Your character array
will be allocated on the stack and so you will get a silent stack
overflow and your program might crash (or worse, it will run and you get
strange effects).

If you use malloc / free for dynamic memory management, you can allocate
all memory you want and check for correct allocation before you try to
use it.

Regards,

Michael



Message has 1 Reply:
  RE: problems with creating arrays of larger sizes
 
(...) Need to understand the difference how array and pointers are being allocated ... And char is usually one or two bytes, depending on type of procesor; and pointer is usually 4 bytes, unless you go to 64-bit processor ... If you wish to utilize (...) (20 years ago, 18-May-04, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  Re: problems with creating arrays of larger sizes
 
OK, here is my code. #include <dmotor.h> #include <dsensor.h> #include <unistd.h> #include <dbutton.h> #include <conio.h> #include <stdio.h> #define n 1000 void verzoegerung(unsigned long zeit) { while(zeit--); } int main() { int i; char c[n]; (...) (20 years ago, 17-May-04, to lugnet.robotics.rcx.legos)

6 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR