Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 28th, 2005, 1:10 PM   #1
Kam
Newbie
 
Join Date: Apr 2005
Posts: 3
Rep Power: 0 Kam is on a distinguished road
n00b question: size of a string?

I'm learning C++ and win32 using Dev-C++.

I wonder if there is a build in Fn to get the size of a string?
eg: my string define as follow:
char mystring[] = "this is my question?"

Thanks.
Kam is offline   Reply With Quote
Old Apr 28th, 2005, 1:20 PM   #2
swayp
Newbie
 
Join Date: Jan 2005
Posts: 3
Rep Power: 0 swayp is on a distinguished road
Yah, to get the size of a string use:

int x;
x = strlen(stringName);
swayp is offline   Reply With Quote
Old Apr 28th, 2005, 1:58 PM   #3
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,473
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
or

string mystring = "this is my question?"

int x = mystring.length();
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Apr 28th, 2005, 2:17 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
BTW, in case you're interested, strlen can be defined as:
int strlen (char *str)
{
    for (int i = 0; *(str + i); i++);
    return i;
}
(Again, I think.)
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:04 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC