If any one has a moment to coment on the use of .cpp tokensCode:// clapp strings.cpp : main project file. #include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace System; int main(array<System::String ^> ^args) { char SingleChar; char mySentence[30] = "My name is Jeff"; /*can initialize a string when declared*/ char yetAnotherSentence[3] = "OR"; int intArr[30]; /* for perspective, will dwell on arrays later in class */ int lenOfMySent; SingleChar = 'K'; printf("The text in mySentence is [%s]\n", mySentence); mySentence[11] = 'S'; /* pick one slot in mySentence which is an array and modify */ mySentence[9] = 'S'; /* pick one slot in mySentence which is an array and modify */ printf("The text in mySentence after updating one alphabet is [%s]\n", mySentence); printf("printing mySentence from 7'th slot onwards [%s]\n", mySentence + 7); printf("scanf is a fragile way of reading a string \n \ 1. One it doesn't read a sentence, will stop at the first space\n \ 2. Will not check whether you've crossed the limit/ size for the string variable\n \ "); printf("\nEnter a word(no space and <=29 in size)\n\tto read into mySentence using scanf :"); scanf("%s", mySentence); /*Look Ma, no & (in front of mySentence)*/ printf("The text in mySentence is with value from user is [%s]\n", mySentence); scanf("%*c"); /*gobble up all extra space to get ready to read the next string*/ printf("\nEnter a sentence(<=29 in size)\n to read into mySentence using fgets :"); fgets(mySentence,29,stdin); printf("The text in mySentence is with value from user with the newline is \n[%s]\n", mySentence); lenOfMySent = strlen(mySentence); /* using the strlen in string.h library to get the length of the mySentence includes the newline that the user entered to indicate done entering the string but does not include the string delimitor */ mySentence[lenOfMySent - 1] = '\0'; /*manually get rid of the newline that the user entered to indicate done entering the string*/ printf("The text in mySentence now that we've taken away the end newline is\n [%s]\n", mySentence); printf("The length of mySentence now that we've taken away the end newline is [%d]\n", lenOfMySent); printf("The sizeof of mySentence (the array) is [%d]\n", sizeof(mySentence)); printf("The sizeof of intArr (the array) is [%d]\n", sizeof(intArr)); system("pause"); return 0; }
I would like to here from you
in addition why is has the code between the brackets failed to word wrap vs continuous line?