473,508 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert char* to char array

9 New Member
char dateStr [10];

_strdate(dateStr)

_strdate(dateStr) is a char * ?? can i convert it to a char[10] ... character array?? any1?

what i mean is assigning the current date to a character array..
Apr 28 '07 #1
7 33597
weaknessforcats
9,208 Recognized Expert Moderator Expert
Read up on arrays.

In C++ the name of the array is the address of elment 0. Therefore, this array:
Expand|Select|Wrap|Line Numbers
  1. char dateStr [10];
  2.  
has a name dateStr that is the address of dateStr[0]. dateStr[0] is a char so dateStr itself is the address of that char, that is, dateStr is a char*.
Apr 28 '07 #2
lalala
9 New Member
hmmm do u mean the dateStr is pointing to the current date?? hmm hmm... btw... is there any ways to store the current date into a character array(no pointer)?? please advise...
Apr 28 '07 #3
Savage
1,764 Recognized Expert Top Contributor
is there any ways to store the current date into a character array(no pointer)?? please advise...
It depands:

Is ur programm suposed to find current date or user input the date?


And us weaknessforcats said char array[] is simmiliar to char *pointer so guess what is the answer for ur question.

Savage
Apr 28 '07 #4
lalala
9 New Member
what i want is assigning the current date to a character array ... something like below :

char dateStr;
char dateJoin[10] = {_strdate(dateStr)};

what i need is assigning the current date to the char dateJoin[10]
Apr 28 '07 #5
Savage
1,764 Recognized Expert Top Contributor
what i want is assigning the current date to a character array ... something like below :

char dateStr;
char dateJoin[10] = {_strdate(dateStr)};

what i need is assigning the current date to the char dateJoin[10]
Use strcat.

This function appends one string to the end of another.Strings are infact array of chars so this should do what u want.Here is function syntax:

char *strcat(char *dest,const char *src);

Note:Before calling function set on [0] element a string terminator('\0' character) in ur dateJoin array.

Savage
Apr 28 '07 #6
lalala
9 New Member
erm... i have got the solution from the internet and i am able to convert it already.. anywayz.. thanks for the guidance and help you offer.. :D
Apr 28 '07 #7
Savage
1,764 Recognized Expert Top Contributor
erm... i have got the solution from the internet and i am able to convert it already.. anywayz.. thanks for the guidance and help you offer.. :D
Well then,I hope it will work correctly!!

Good luck!!!

Savage
Apr 28 '07 #8

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

Similar topics

5
22007
by: Brad Moore | last post by:
Hey all, I'm getting the following compiler error from my code. I was wondering if anyone could help me understand the concept behind it (I actually did try and compile this degenerate...
27
51646
by: Trep | last post by:
Hi there! I've been having a lot of difficult trying to figure out a way to convert a terminated char array to a system::string for use in Visual C++ .NET 2003. This is necessary because I...
19
4109
by: jeff | last post by:
how do you convert form byte to Int32 while retaining the binary value of the byte array
13
7873
by: Bryan Parkoff | last post by:
I have two variables: "char A" and "short B". I can be able to convert from A to B using explicit case conversion with no problem like "B = short (A);". Right now, I have two variables: "char T"...
15
34566
by: Kueishiong Tu | last post by:
How do I convert a Byte array (unsigned char managed) to a char array(unmanaged) with wide character taken into account?
12
10054
by: GRoll35 | last post by:
I get 4 of those errors. in the same spot. I'll show my parent class, child class, and my driver. All that is suppose to happen is the user enters data and it uses parent/child class to display...
5
6233
by: Koolrans | last post by:
Hi All, Don't know if this is covered somewhere else. Could not find it. I have a problem for which I need a solution. I have an array of char chr. I want to convert this to an array of...
8
16234
by: Frank Liebelt | last post by:
Hi I try to convert a int array into a char array. My code: void exec() { char mds; int i; int mdc =...
12
13509
by: Peter | last post by:
Trying to convert string to byte array. the following code returns byte array of {107, 62, 194, 139, 64} how can I convert this string to a byte array of {107, 62, 139, 65} ...
14
13430
by: rtillmore | last post by:
Hello, I did a quick google search and nothing that was returned is quite what I am looking for. I have a 200 character hexadecimal string that I need to convert into a 100 character string. ...
0
7231
marktang
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,...
0
7133
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...
0
7336
Oralloy
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,...
0
7405
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...
1
7066
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...
0
5643
agi2029
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,...
1
5059
isladogs
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...
0
4724
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...
0
435
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...

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.