473,383 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

dynamic charecter in c & output format

86
ok i have two problems...

firstly in strict C enviornment is it possible to have a true dynamic charecter array with no predefined length...i mean to say...

suppose..

char *array =NULL;
/*
actually i dnt know what the exact size of my string is so i aquire sace for 1 charecter from heap
/*
array =(char *)malloc(sizeoof(char));

/* now i input a string using this pointer to charecter*/
gets(array);
/* in know this is a bad idea but what are the altarnatives */
....
....

delete array;
/* this is bound to give a warning:HEAP during debuggn as i requested only for a space for 1 charecter */

so wat can be done to avoid this.....


one more question...

like is c we have an output format...printf("%0.2f", sum_float);
is there similar things in c++.....
May 8 '07 #1
2 1995
Savage
1,764 Expert 1GB
ok i have two problems...

firstly in strict C enviornment is it possible to have a true dynamic charecter array with no predefined length...i mean to say...

suppose..

char *array =NULL;
/*
actually i dnt know what the exact size of my string is so i aquire sace for 1 charecter from heap
/*
array =(char *)malloc(sizeoof(char));

/* now i input a string using this pointer to charecter*/
gets(array);
/* in know this is a bad idea but what are the altarnatives */
....
....

delete array;
/* this is bound to give a warning:HEAP during debuggn as i requested only for a space for 1 charecter */

so wat can be done to avoid this.....


one more question...

like is c we have an output format...printf("%0.2f", sum_float);
is there similar things in c++.....
Sure,check it out here

Savage
May 8 '07 #2
ayan4u
86
Sure,check it out here

Savage
thanks but that was of little help.....firstly i am in pure C enviornment...i.e, no "new"....secondly i donot know the length before hand....so cannot use array....can you elaborate about what you are suggesting....
May 9 '07 #3

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

Similar topics

1
by: DrTebi | last post by:
Hello, I have the following problem: I used to "encode" my email address within links, in order to avoid (most) email spiders. So I had a link like this: <a...
4
by: John Bowman | last post by:
Hi, A couple Q's , so I've come to the experts<g>. 1) I need a definitive answer to the following debate. I've got a couple developers who disagree on the following question. We've got an XML...
21
by: Marky C | last post by:
atof is not working. double a = atof("12.345"); a gets set to 12.000 I am working on a toshiba micro. The data map has no space allocated to it for dynamic memory. Does anyone have an...
9
by: Durgesh Sharma | last post by:
Hi All, Pleas help me .I am a starter as far as C Language is concerned . How can i Right Trim all the white spaces of a very long (2000 chars) Charecter string ( from the Right Side ) ? or how...
7
by: Joey | last post by:
I don't care what .net language this come in but I really need to determine if a disk is dynamic or basic. I have posted something in the WMI group but no one knows how to do it. Does anyone have...
7
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
5
by: jhurrell | last post by:
I have been having some trouble getting my XSL style sheet to parse correctly. I have some XML outputted from an SQL-Server, that I then need to turn into multiple HTML files. This I have done...
2
by: mail2ravi123 | last post by:
hi all, plz provide me a function that is used to compare wild char and as well as to compare * charecter and \ charecter in the string FYI if we want to compare a string for * charecter then...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.