-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringReverse.cpp
More file actions
53 lines (43 loc) · 914 Bytes
/
StringReverse.cpp
File metadata and controls
53 lines (43 loc) · 914 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
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Screen.h"
void usage( char* pName )
{
if( pName == NULL )
return;
fprintf(stdout, "Usage: %s String\n", pName);
fprintf(stdout, "Ex) %s ABCDEFG\n", pName);
}
int main( int argc, char** argv )
{
char* pBuffer = NULL;
unsigned int nLength = 0;
/* UNUSED Variables */
/*
( void ) argc; ( void ) argv;
*/
// Test Situation of Arguments.
//char bBuffer[] = "String Rerverse using Stack";
//char bBuffer[] = "String";
//char bBuffer[] = "";
//char* bBuffer = NULL;
//char bBuffer[] = "ÇÑ±Û TEST";
//char bBuffer[] = "-A";
if(argc < 2)
{
usage( argv[0] );
return -1;
}
nLength = strlen( argv[1] );
pBuffer = (char *) malloc( nLength );
memset( pBuffer, 0, nLength );
strncpy( pBuffer, argv[1], nLength );
Screen( pBuffer );
if( pBuffer != NULL )
{
free(pBuffer);
pBuffer = NULL;
}
return 0;
}