-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc11_for2.cpp
More file actions
46 lines (37 loc) · 989 Bytes
/
c11_for2.cpp
File metadata and controls
46 lines (37 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* =====================================================================================
*
* Filename: forstr.cpp
*
* Description:
*
* Version: 1.0
* Created: 2015年09月17日 15时27分42秒
* Last Modified: 2017-12-31 12:16:14
* Revision: none
* Compiler: gcc
*
* Author: zt (),
* Organization:
*
* =====================================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
int main ( int argc, char* argv[] )
{
( void ) argc;
( void ) argv;
std::string str = "1233444";
char a[] = "1233444";
for ( auto ele : str )
printf ( "%c ", ele );
printf ( " size = %ld \n", str.size() );
printf ( "strlen = %ld\n", strlen ( str.c_str() ) );
printf ( "strlen = %ld\n", sizeof ( str.c_str() ) );
printf ( "strlen a = %ld\n", strlen ( a ) );
printf ( "strlen a = %ld\n", sizeof ( a ) );
return 0;
}