Hi,
I have declared pointer of pointers **a;
so In a loop I assign a block to a pointer and put a value in it
and then I want to print these values.
My following program doesnt work.
Also How to do same program with int *a[]; (array of pointers).
Any help would really help.
#include <stdio.h>
#include <conio.h>
#include <malloc.h>
void main()
{
int **a;
int v=0;
for (v=0;v<5;v++)
{
*(a+v)=(int *)malloc(sizeof (int));
**(a+v)=v;
}
for (v=0;v<5;v++)
{
printf("%d\n",* *(a+v));
}
exit(0);
}
Feb 24 '06
27 1819 fr*******@yahoo .com wrote:
Your response belongs *under* the text you are replying to, not above it. ok guys whaterver u told , it helped me..
Please don't use contractions like "u" you "you" and "ur" for "your". It
makes it *far* harder for others to read what you are saying. In
general, since you want people to help you be nice to them by writing
properly or why should we put in the effort to solve your problems?
but who will free the allocated memory.. ur fathers????
<snip>
If you allocate memory it is up to you to deallocate it. That's why
there is a free function as well as malloc and realloc.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro: http://clc-wiki.net/wiki/Intro_to_clc
Flash Gordon Please don't use contractions like "u" you "you" and "ur" for "your". It makes it *far* harder for others to read what you are saying.
I dont udenrstand why people can not understand "u" and "ur"
If you can understand C, C++ and complicated coding then its very easy
to understand
i which context "u" and "ur" is used. We are not writing the post to
mr. president to be so correct.
Thanks anyway for your feedback.
bye
cric. fr*******@yahoo .com wrote: Flash Gordon
Please don't use contractions like "u" you "you" and "ur" for "your". It makes it *far* harder for others to read what you are saying.
I dont udenrstand why people can not understand "u" and "ur" If you can understand C, C++ and complicated coding then its very easy to understand i which context "u" and "ur" is used. We are not writing the post to mr. president to be so correct.
I'm sure Mr. President wouldn't be happy at your lack of respect.
Silly phonetic abbreviations can be /very/ hard for non-native English
speakers to decode. I'm sure you do have some consideration (if not
respect) for them, don't you? Otherwise: Hau vud ju lajk if aj vrote in
vot aj konsider tu be fonetik ingliš?
Even for native or fluent English speakers they require extra effort to
decode (unless they learned it from age 3, I guess).
Also, /especially/ people who /really/ understand C (C++ is off-topic,
and not necessarily well understood in these parts), live and breathe
syntax correctness, and "u" and "ur" are certainly not correct English
syntax (also, look up "ur" in any German dictionary; C does not support
mixed language programming either).
Hope this clarifies this a little bit for you.
--
BR, Vladimir
From a certain point onward there is no longer any turning back.
That is the point that must be reached.
-- F. Kafka fr*******@yahoo .com wrote: I have declared pointer of pointers **a; so In a loop I assign a block to a pointer and put a value in it and then I want to print these values.
My following program doesnt work.
Also How to do same program with int *a[]; (array of pointers). Any help would really help.
#include <stdio.h> #include <conio.h> #include <malloc.h>
void main() { int **a; int v=0;
for (v=0;v<5;v++) { *(a+v)=(int *)malloc(sizeof (int)); **(a+v)=v; }
for (v=0;v<5;v++) { printf("%d\n",* *(a+v)); } exit(0); }
You are missing the "backbone" allocation. int ** a, is a pointer to
storage which itself points to additional storage for each integer.
You've allocated the storage for each integer, but not to the big
structure to hold these pointers.
If your compiler has good warnings, you could try to crank the warning
levels up and it should tell you that the line with *(a+v) = ... is
writing to the other end of (a+v) without that pointer having
initilizing it. It seems to me that you have to put something like:
a = (int **) malloc (5 * sizeof (int *));
at the beginning.
Remember that each * in your declaration requires you to point that
level at some storage (or to malloc it) directly in your code, while
each [] in your declaration implicitely declares its own storage for
that level (but may require you to calculate the sizeof() in mallocs at
higher levels carefully).
--
Paul Hsieh http://www.pobox.com/~qed/ http://bstring.sf.net/ fr*******@yahoo .com wrote: Flash Gordon
Please don't use contractions like "u" you "you" and "ur" for "your". It makes it *far* harder for others to read what you are saying.
I dont udenrstand why people can not understand "u" and "ur" If you can understand C, C++ and complicated coding then its very easy to understand i which context "u" and "ur" is used. We are not writing the post to mr. president to be so correct.
Congratulations : you are now officially too stupid to help.
Richard rl*@hoekstra-uitgeverij.nl (Richard Bos) writes: fr*******@yahoo .com wrote:
Flash Gordon
> Please don't use contractions like "u" you "you" and "ur" for "your". It > makes it *far* harder for others to read what you are saying.
I dont udenrstand why people can not understand "u" and "ur" If you can understand C, C++ and complicated coding then its very easy to understand i which context "u" and "ur" is used. We are not writing the post to mr. president to be so correct.
Congratulations : you are now officially too stupid to help.
I suggest giving "free2cric" a break, at least tentatively. He admits
not understanding the problem; it's entirely possible that he's
capable of learning. (Even though he's been posting sporadically to
comp.lang.c for over a year, he might have missed the repeated
discussions of why silly abbreviations are a bad idea.)
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
On 2006-02-27, Vladimir S. Oka <no****@btopenw orld.com> wrote: fr*******@yahoo .com wrote:
Silly phonetic abbreviations can be /very/ hard for non-native English speakers to decode. I'm sure you do have some consideration (if not respect) for them, don't you? Otherwise: Hau vud ju lajk if aj vrote in vot aj konsider tu be fonetik ingli??
Even for native or fluent English speakers they require extra effort to decode (unless they learned it from age 3, I guess).
Also, /especially/ people who /really/ understand C (C++ is off-topic,
In many circles constant /hiliting/ is seen as obnoxious and
boring. It lights my newsreader like a beacon and for those that don't
support it, it breaks up the English. Please refrain from doing it so
frequently. It is really, really nasty.
and not necessarily well understood in these parts), live and breathe syntax correctness, and "u" and "ur" are certainly not correct English syntax (also, look up "ur" in any German dictionary; C does not support mixed language programming either).
Hope this clarifies this a little bit for you. fr*******@yahoo .com wrote: Hi, I have declared pointer of pointers **a; so In a loop I assign a block to a pointer and put a value in it and then I want to print these values.
My following program doesnt work.
Also How to do same program with int *a[]; (array of pointers). Any help would really help.
#include <stdio.h> #include <conio.h> #include <malloc.h>
void main() { int **a; int v=0;
for (v=0;v<5;v++) { *(a+v)=(int *)malloc(sizeof (int)); **(a+v)=v; }
for (v=0;v<5;v++) { printf("%d\n",* *(a+v)); }
exit(0);
}
You probably want something like the following.
#include <stdio.h>
#include <stdlib.h>
#define LEN 5
int main(void)
{
int **a;
int k = 0;
a = malloc(sizeof *a);
a[0] = malloc(LEN * sizeof **a);
for (k = 0; k < LEN; k++) { a[0][k] = k; }
for (k = 0; k < LEN; k++) { printf("%d\n", a[0][k]); }
return 0;
}
August
--
I am the "ILOVEGNU" signature virus. Just copy me to your
signature. This email was infected under the terms of the GNU
General Public License.
Vladimir S. Oka wrote: fr*******@yahoo .com wrote:
Flash Gordon
Please don't use contractions like "u" you "you" and "ur" for "your". It makes it *far* harder for others to read what you are saying. I dont udenrstand why people can not understand "u" and "ur" If you can understand C, C++ and complicated coding then its very easy to understand i which context "u" and "ur" is used. We are not writing the post to mr. president to be so correct.
I'm sure Mr. President wouldn't be happy at your lack of respect.
Silly phonetic abbreviations can be /very/ hard for non-native English speakers to decode. I'm sure you do have some consideration (if not
<snip>
They are also very difficult for certain groups of *native* English
speakers, such as dyslexics (i.e. me). I, for example, will often have
to read a paragraph using those contractions at least twice before I
understand it, the second time much more slowly than normal. If they are
used more that a couple of times I might have to read it several times
because by the time I've decoded "ur" as "your" I've forgotten the rest
of the paragraph.
Given enough *years* of exposure, or months of *real* effort, it is
possible I might become fluent in such contractions. However, unless
someone is going to pay me a *lot* of money to do something that for me
is far harder than programming and which I do not enjoy at all, then I'm
not going to learn these contractions until they have been used in
normal English for several years.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro: http://clc-wiki.net/wiki/Intro_to_clc This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike Henley |
last post by:
I first came across rebol a while ago; it seemed interesting but then
i was put off by its proprietary nature, although the core of the
language is a free download.
Recently however, i can't help but say i was totally impressed. I
needed an open source wikiblog/wikilog, whatever you wanna call it,
basically a hybrid of a blog and a wiki. I checked out snipsnap, which
uses java, it was said on their site to be a clone of vanilla, a...
|
by: E. Robert Tisdale |
last post by:
What makes a good C/C++ programmer?
Would you be surprised if I told you that
it has almost nothing to do with your knowledge of C or C++?
There isn't much difference in productivity, for example,
between a C/C++ programmers with a few weeks of experience
and a C/C++ programmer with years of experience.
You don't really need to understand the subtle details
or use the obscure features of either language
|
by: typingcat |
last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so
on. I've tried many PHP IDEs today, but almost non of them supported
Unicode (UTF-8) file.
I've found that the only Unicode support IDEs are DreamWeaver 8 and
Zend PHP Studio.
DreamWeaver provides full support for Unicode. However, DreamWeaver is
a web editor rather than a PHP IDE. It only supports basic IntelliSense
(or code completion) and doesn't have anything...
|
by: Madhur |
last post by:
Hello
what about this nice way to open a file in single line rather than using
if and else.
#include<stdio.h>
void main()
{
FILE *nd;
clrscr();
fopen("c:\\autoexec.bat","r")&&printf("success") || printf("error opeing
|
by: Pyenos |
last post by:
import cPickle, shelve
could someone tell me what things are wrong with my code?
class progress:
PROGRESS_TABLE_ACTIONS=
DEFAULT_PROGRESS_DATA_FILE="progress_data"
PROGRESS_OUTCOMES=
| |
by: Siong.Ong |
last post by:
Dear all,
my PHP aims to update a MySQL database by selecting record
one by one and modify then save.
Here are my PHP, but I found that it doesnt work as it supposed to be,
for example, when Record (i) is shown and modified, the change will
come to Record (i+1).
Can anyone provide suggestion?
thanks.
|
by: Tubular Technician |
last post by:
Hello, World!
Reading this group for some time I came to the conclusion that
people here are split into several fractions regarding size_t,
including, but not limited to,
* size_t is the right thing to use for every var that holds the
number of or size in bytes of things.
* size_t should only be used when dealing with library functions.
|
by: Daniel.C |
last post by:
Hello.
I just copied this code from my book with no modification :
#include <stdio.h>
/* count characters in input; 1st version */
main()
{
long nc;
nc = 0;
|
by: MU |
last post by:
Hello
I have some code that sets a dropdownlist control with a parameter
from the querystring. However, when the querystring is empty, I get
an error.
Here is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
|
by: mingke |
last post by:
Hi...
So I have problem with my if condition..I don't know what's wrong but it keeps resulting the wrong answer....
So here's the part of my code I have problem with:
for (i=0; i<size2; i++){
for (k = 0; k < point3; k++){
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
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...
| |