1 parent
146fb788a6
commit
eb1cdc34a3
13 files changed
+230
-18
No files matched your search
Binary file not shown.
Binary file not shown.
@@ -19,7 +19,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
|
||||
@@ -1,39 +1,60 @@
|
||||
/******************************************************************************
|
||||
* Program: COM 390 - Project 1
|
||||
* Author: Amrit Panesar <apanesar-77260@student.coleman.edu
|
||||
* Date: 2015-08-11
|
||||
* Purpose: Prompt the user for their name, display the fact that they enjoy
|
||||
* programming in C, and state that it is indeed a piece of cake.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <string.h>
|
||||
|
||||
const char* HELLO ="I love Porgramming in C\n";
|
||||
const char* TOKENS = " ";
|
||||
const int TOKENINDEX = 1; // insert name after token 0
|
||||
const char* CAKE = " \xdc\n \xdb\n \xdc\xdc \xdc\xdf\n \xdc\xdb\xdb\xdb\xdb\xdb\xdb\xdc \xdc\xdc\xdc\xdc\xdc\xdc\xdb\xdb\xdb\xdf\xdb\n \xdc\xdb \xdb\xdb\xdb\xdb\xdb\xdb\xdb \xdb\xdb\xdf\xdf\xdf \xdc\xdc\xdb\xdf\xdb\xdc\xdb\xdb\xdb\n \xdb\xdf\xdf\xdf \xdb\xdb\xdb\xdb\xdb\xdf\xdf\xdc\xdb\xdf\xdc\xdc\xdf\xdf\xdc\xdc\xdb\xdb\xdb\xdb\xdb\xdb\xdb\n \xdb\xdf\xdc\xdc\xdc\xdc\xdb\xdb\xdb \xdc\xdc\xdb\xdf\xdf\xdc\xdc\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdf\xdf\xdc\xdc\n \xdb \xdf\xdf\xdf\xdf\xdf\xdf\xdc\xdc\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdf\xdf\xdc\xdc\xdb\xdb\xdb\xdb\n \xdb \xdb\xdb\xdb\xdb\xdb\xdf\xdf\xdf\xdc\xdc\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdf\n \xdb \xdb\xdf\xdf \xdc\xdc\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdf\xdb\xdc\xdc\xdb\n \xdb \xdc\xdc\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdf\xdb\xdc\xdb\xdb\xdb\xdb\xdb\xdb\n \xdb \xdb\xdb\xdb\xdb\xdf\xdf\xdc\xdc\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdf\xdf\n \xdb \xdf\xdf\xdc\xdc\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdf\xdf\n \xdb \xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdf\xdf\n \xdf\xdc\xdc\xdc \xdb\xdb\xdb\xdf\xdf\n \xdf\xdf\xdf\xdf\xdf\xdf";
|
||||
|
||||
const char* HELLO ="I love Programming in C\n";
|
||||
|
||||
const char* TOKENS = " ";
|
||||
|
||||
const int TOKENINDEX = 1; // insert name after token 0
|
||||
|
||||
char name[256], out[256];
|
||||
char* token, nextToken = NULL;
|
||||
char *token, *nextToken = NULL;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int i = 0;
|
||||
|
||||
printf("%s\n:", "Please enter your name");
|
||||
gets_s(name, sizeof(name));
|
||||
|
||||
strcpy(out, HELLO);
|
||||
// lets begin
|
||||
|
||||
token = strtok_s(out, TOKENS, &nextToken);
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
for (int i = 0; token != NULL; i++) {
|
||||
printf("%s\n:", "Please enter your name"); // prompt for name
|
||||
gets_s(name, sizeof(name)); // set the string into the buffer
|
||||
printf("\n\n"); // new lines
|
||||
|
||||
strcpy(out, HELLO); // copy the string to be tokenized into a mutable buffer
|
||||
|
||||
token = strtok(out, TOKENS); // start the tokenizer
|
||||
|
||||
for (i = 0; token != NULL; i++) // time to loop over the tokens
|
||||
{
|
||||
if (i == TOKENINDEX) {
|
||||
printf(", %s,", name);
|
||||
printf(", %s,", name); // insert after the token index
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
printf("%s", token);
|
||||
printf("%s", token); // token 0 does not get a space (anticipation for name/token 1)
|
||||
} else {
|
||||
printf(" %s", token);
|
||||
printf(" %s", token); // display a space followed by the token data
|
||||
}
|
||||
|
||||
token = strtok_s(NULL, TOKENS, &nextToken);
|
||||
token = strtok(NULL, TOKENS); // delta next token
|
||||
}
|
||||
|
||||
printf("\n%s\n", "Press any key to continue. . .");
|
||||
_getch();
|
||||
printf("\n\n%s\n%s\n", "It's a piece of cake!", CAKE); // cake
|
||||
|
||||
return 0;
|
||||
printf("\n%s\n", "Press any key to continue. . .");
|
||||
getch(); // pause
|
||||
|
||||
return 0; // done!
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user