Skip to content

Commit b51556e

Browse files
committed
added first string function
1 parent 958a739 commit b51556e

File tree

7 files changed

+56
-1
lines changed

7 files changed

+56
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ main(){
1919
std::string MyString = "hello world";
2020

2121
// call function
22-
MyArray = JS::stringToVector(MyString);
22+
MyArray = js::stringToVector(MyString); // returns a vector
2323

2424
}
2525
```

a.out

14.1 KB
Binary file not shown.

jackstring/jackstring.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <string>
4+
#include "jackstring.h"
5+
6+
namespace js{
7+
int jackLength(std::string str){
8+
int count = 0;
9+
for (int i = 0; i < str.length(); ++i)
10+
{
11+
count++;
12+
}
13+
return count;
14+
}
15+
}

jackstring/jackstring.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef JACKSTRING_H
2+
#define JACKSTRING_H
3+
4+
#include <iostream>
5+
#include <vector>
6+
#include <string>
7+
8+
// class Jackstring{
9+
// private:
10+
// std::string str;
11+
12+
// public:
13+
// Jackstring();
14+
// }
15+
namespace js{
16+
int jackLength(std::string str);
17+
18+
}
19+
20+
#endif

jackvector/jackvector.cpp

Whitespace-only changes.

jackvector/jackvector.h

Whitespace-only changes.

main.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <string>
4+
#include "jackstring/jackstring.h"
5+
using namespace std;
6+
// using namespace js;
7+
void loop(vector<int> arr){
8+
// int i ;
9+
for( int i = 0; i < arr.size(); ++i){
10+
cout << i << endl;
11+
}
12+
}
13+
14+
int main(){
15+
string str = "data";
16+
int a = js::jackLength(str);
17+
cout << a ;
18+
19+
return 0;
20+
}

0 commit comments

Comments
 (0)