The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C++ Code
Posted by: bug | December 21, 2009 @ 12:10am
C++ Code
[
Download
]
#include <iostream> #include <math.h> using namespace std; int main() { // try replacing the declaration below //with this one //char x[]= {'a','b','c','d'}; //create a c string...the null terminator is automatically added char x[10] ="abcd"; for(int i=0; x[i]!= '\0';i++){ cout <<"x["<<i<<"] : "<< x[i]<<endl; } cout<<"\n-Now with a While Loop-"<<endl; int count= 0; while(x[count] != '\0'){ cout <<"x["<<count<<"] : "<< x[count++]<<endl; } // Try uncommenting the lines below to see what happens //x ="wxyz"; // char y[10]; //char * strcpy ( char * destination, const char * source ) cout<<"\n-copy x to y-"<<endl; strcpy(y,x); count=0; while(y[count] != '\0'){ cout <<"y["<<count<<"] : "<< y[count++]<<endl; } if(x==y) cout<<"\nThey are equal"<<endl; else cout<<"\nThey are not equal"<<endl; if(strcmp(x,y)==0) cout<<"\n strcmp(x,y) is true"<<endl; else cout<<"\nstrcmp(x,y) is false"<<endl; }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.33 / 8
64 Votes
http://codebin.yi.org/435
page generated in 0.00 seconds