hi
i want to create an array of strings .I know the number of items that
the array will contain but the size of each string will be different
and will not be known at compile time.
eg: in
char * mynames[]
mynames[0]="mathew"
mynames[1]="gordon_bro wn"
mynames[2]="F:\gordon\doc s\mycv.txt"
how can i allocate the memory for this array? I know malloc() and
free() need to be used but not sure since i am only a beginner
thanx in adv
gordon
Jan 23 '08
12 1547
Keith Thompson wrote:
>
.... snip ...
>
This article was written by Keith Thompson <ks***@mib.org> .
Permission to quote without attribution is explicitly denied for
this message and for every message I post here.
I like this.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
--
Posted via a free Usenet account from http://www.teranews.com
On Wed, 23 Jan 2008 15:15:11 +0000, Richard Tobin wrote:
In article <fn**********@r egistered.motza rella.org>, santosh
<sa*********@gm ail.comwrote:
>>>i want to create an array of strings .I know the number of items that the array will contain but the size of each string will be different and will not be known at compile time.
[...]
>>>mynames[0]="mathew" mynames[1]="gordon_bro wn" mynames[2]="F:\gordon\doc s\mycv.txt"
He specifically says above that the sizes of the strings will not be known at compile time.
He also gives an example in which they are, so he might be confused.
He also uses some odd characters in his example. What, pray tell, does
\g do? Or \d? \m?
In article <no************ @spanky.localho st.net>,
Kelsey Bjarnason <kb********@gma il.comwrote:
>>>>mynames[0]="mathew" mynames[1]="gordon_bro wn" mynames[2]="F:\gordon\doc s\mycv.txt"
>>>He specifically says above that the sizes of the strings will not be known at compile time.
>He also gives an example in which they are, so he might be confused.
>He also uses some odd characters in his example. What, pray tell, does \g do? Or \d? \m?
I think that problem was addressed several days ago.
-- Richard
--
:wq This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Atip Asvanund |
last post by:
Dear sirs,
I am trying to learn how to use Boehm's garbage collector:
http://www.hpl.hp.com/personal/Hans_Boehm/gc/ on a Linux machine. I am
a beginner, and I find its documentation inadequate. I have followed
all instructions for installation, yet I still have the following
questions.
1) The instruction said to include the header file, and link to the
library file. I was wondering if I am doing it correctly in my
|
by: sathyashrayan |
last post by:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct tree
{
int data;
struct tree *left,*right;
};
void init(struct tree *node)
|
by: rory |
last post by:
Cna anyone point me in the right direction, I have a struture in my .h
file:
typedef struct mdata
{
int names;
int dates;
int ages;
}m_Data;
|
by: Yourko |
last post by:
Hi there! I`me currently trying to write some simple programs in C.
For one such program i created globals.h file. In that file i defined a structure of type _client, and a pointer of that type:
struct _client{
int fd; // file descriptor
struct sockaddr_in sock_name;
} * client;
Later in that program i do:
client = (struct _client *) malloc(sizeof(struct _client));
|
by: AG |
last post by:
Hello,
This is my first post to this group, and on top of that I am a
beginner. So please direct me to another group if this post seems out
of place....
I have recently written a program which calculates loan
amortization schedules, writes the data to a text file, and then upon
user prompt, the program will display the created file and print the
file. Until this morning, everything worked fine, and then I started
messing around with...
| |
by: raam |
last post by:
hi all,
I trying to write an array of integers into a text
file.While writing into the file it works.I used fwrite function, but
when I read the same file using fread or fscanf it fails and it prints
some junk.I am not opening the file in binary mode, there are no
characters which will terminate the fscanf function operation.How to
write and read the integer array .
Thanks in advance.
|
by: fool |
last post by:
Dear group,
Extract the integer value present in a given string. So I tried the
following:
int main(void)
{
int val;
char *data;
data = malloc(sizeof *data);
if(data)
|
by: fool |
last post by:
Dear group,
I want to check if the given string is a number. If any value is
inputed other than a number then error. The following is not the correct
solution. Can some one tell me any link for the above task? Pls just
don't give the code. Thanks.
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
|
by: hal |
last post by:
Hi,
I'm trying to make an array of pointers to 'TwoCounts' structs, where
the size of the array is arraySize. Right now I'm just mallocing
enough space for all the pointers to the structs, and mallocing space
for the pointer 'countPtr' in each struct, but do I need to do
anything else? Thanks.
typedef struct TwoCounts {
int *countPtr;
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: 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();...
|
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: 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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |