Skip to content

Instantly share code, notes, and snippets.

@samehkamaleldin
Created May 1, 2015 17:18
Show Gist options
  • Save samehkamaleldin/ab7ad5e26135d822adae to your computer and use it in GitHub Desktop.
Save samehkamaleldin/ab7ad5e26135d822adae to your computer and use it in GitHub Desktop.
Function Cut
#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;
}
@samehkamaleldin
Copy link
Author

This is not a valid program code as it don't have main function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment