Skip to content

Commit 8420003

Browse files
committed
added a charToString Function and updated readMe file. Tested!
1 parent 85e1ef7 commit 8420003

6 files changed

Lines changed: 15 additions & 2 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ main(){
2525
int b = js::includes(str2, str);
2626
cout << b << endl; // returns 3
2727

28+
/////////////////////////////
29+
//convert a char to a string
30+
char myChar = 'A';
31+
string str3 ;
32+
str3 = js::charToString(myChar);
33+
cout << str3 << endl; // returns "A"
34+
2835
return 0;
2936
}
3037
```

jackstring/jackstring.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ namespace js{
3030
}
3131
return -1;
3232
}
33+
34+
std::string charToString(char charector){
35+
std::string str;
36+
str.push_back(charector);
37+
return str;
38+
}
3339
}

jackstring/jackstring.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace js{
99
int length(std::string str);
10-
int includes(std::string text, std::string str); // returns 1 else -1
11-
10+
int includes(std::string text, std::string str); // returns 1 else -1.
11+
std::string charToString(char); // converts a charector to a string.
1212
}
1313

1414
#endif

jackstring/jackstring.o

1.17 KB
Binary file not shown.

main.o

-528 Bytes
Binary file not shown.

output

152 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)