Created
May 1, 2015 17:18
-
-
Save samehkamaleldin/ab7ad5e26135d822adae to your computer and use it in GitHub Desktop.
Function Cut
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <cmath> | |
#include <cstdlib> | |
#include <sstream> | |
using namespace std; | |
string cut(string ) // error 1: there should be var name not type only. | |
{ | |
string x; | |
int i; | |
int g = x.length(); // error 2: x hasn't be initialized with any value to measure its length | |
string h; | |
for(i=0;i<g;i++) | |
{ | |
h=x.substr(i,i+1); // error 3: the same as 2 be for variable h | |
if(x.substr(0,1)!="[") | |
{ | |
return "error"; | |
break; | |
} | |
if (h==" "||h=="["||h=="]") | |
{ | |
h.erase(i-1,i); | |
} | |
if(h=="]") | |
break; | |
} | |
return h; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is not a valid program code as it don't have
main
function