示例#1
0
void OsConfigDb::storeToBuffer(char *buff) const
{
    char *p = buff;
    int n = numEntries();
    for (int i = 0; i < n; i++)
    {
        DbEntry *pEntry = (DbEntry *)mDb.at(i);
        removeChars(&pEntry->key, '\r');
        removeChars(&pEntry->value, '\n');

        sprintf(p, DB_LINE_FORMAT, (char *)pEntry->key.data(),
                (char *)pEntry->value.data());

        p = buff + strlen(buff);
    }
}
示例#2
0
main() {
    char str[] = "acaabcbbdd";
    char str2[] = "Battle of the Vowels: Hawaii vs. Grozny";
    char remove[] = "aeiou";

    char *dstr = removeChars(str2, remove);
    printf("str[%s] dstr[%s]\n", str2, dstr);

    free(dstr);
    removeDuplicates(str);
}
void parseRecoverOpt (basl::ErrorRec & error_rec)
{
    util::String const & opt_rec = conf::getOptionValue (conf::opt_rec);
    // remove spaces from string, if empty do nothing
    String str = removeChars (opt_rec, " \t");
    if (! str.empty ())
    {
        ParseRecoverOpt parser (str.begin (), str.end (), error_rec);
        parser.parse ();
    }
}
示例#4
0
void test_removeChars()
{
    std::cout << "########################################" << std::endl;
    std::cout << __FUNCTION__ << std::endl;
    std::cout << "########################################" << std::endl;

    const char * r = "aeiou";
    const char * t = "Battle of the Vowels: Hawaii vs. Grozny";
    std::cout << "Original string: " << t << std::endl;
    std::cout << "Transformed string: " << removeChars(r, t) << std::endl;

    std::cout << std::endl;
}
int main(void) {

	char str[] = "abc-abc-abc-abc-abc-abc";
	char * rem = "b-";

	printf("remove '%s'...\n", rem);
	printf("%s\n",str);

	removeChars(str, rem);
	printf("%s\n",str);

	return 0;
}
示例#6
0
文件: main.c 项目: sonesh/practice
int main (int argc, char *argv[]) {

  char inputString[MAX_LEN_STR + 1];
  char removeString[MAX_LEN_STR + 1];
  char *newLine;

  int i = 0;
  for (i = 0; i < MAX_NUM_CHAR; i++) {
    charHashTable[i] = 0;
  }

  //Read inputString
  printf("Enter inputString:\n");
  if (fgets(inputString, sizeof(inputString), stdin) != NULL) {
    //remove newline
    if ((newLine = strchr(inputString, '\n')) != NULL)         
      *newLine = '\0';
  } else {
    printf("Error reading inputString. Exiting\n");
    return EXIT_FAILURE;
  }

  //Read removeString
  printf("Enter removeString:\n");
  if (fgets(removeString, sizeof(removeString), stdin) != NULL) {
    //remove newline
    if ((newLine = strchr(removeString, '\n')) != NULL)         
      *newLine = '\0';
  } else {
    printf("Error reading removeString. Exiting\n");
    return EXIT_FAILURE;
  }  

  printf("Original string:\n");
  printf("%s\n", inputString);

  printf("\n");
  printf("Removal chars:\n");
  printf("%s\n", removeString);

  removeChars(inputString, removeString);

  printf("\n");
  printf("Edited string:\n");
  printf("%s\n", inputString);

  return EXIT_SUCCESS;
}
int main(int argc, char *argv[]) {
    std::ifstream fid;
    std::string line;
    fid.open(argv[1],std::ios::in);
    if(!fid.is_open()) {
        printf("Error opening file.\n");
        return 1;
    }
    while(!fid.eof()) {
        getline(fid,line);
        if(line.size() == 0) {
            continue;
        }
        std::string scrubbed = removeChars(line);
        printf("%s\n",scrubbed.c_str());
    }
    return 0;
}
bool Line::addChar(char xiChar)
{
    Logger::Log("Entering Line.addChar (char)...", LOG_DEBUG);

    if (xiChar == 8) // delete
    {
        Logger::Log("Removing a character from this line.", LOG_DEBUG);
        removeChars(1);
        return true;
    }
    else
    {
        Logger::Log("Adding a character to this line.", LOG_DEBUG);
        string* lAppendable = new string("");
        lAppendable->append(1, xiChar);
        bool addResult = addText(lAppendable);
        delete lAppendable;
        return addResult;
    }
}
示例#9
0
void SC2Map::makeMapNameValidForFilenames()
{
  mapNameInOutputFiles.assign( mapName );

  // remove invalid filename characters
  removeChars( "\\<>:\"/|?*\t\r\n ", &mapNameInOutputFiles );

  // gotta start with an alpha character
  if( !isalpha( mapNameInOutputFiles[0] ) )
  {
    string prefix( "sc2map" );
    prefix.append( mapNameInOutputFiles );
    mapNameInOutputFiles.assign( prefix );
  }

  set<string>::iterator sItr = mapFilenamesUsed.find( mapNameInOutputFiles );
  if( sItr != mapFilenamesUsed.end() )
  {
    int    number = 2;
    string alternateName;
    do
    {
      char alt[FILENAME_LENGTH];
      sprintf( alt, "%s%d", mapNameInOutputFiles.data(), number );
      alternateName.assign( alt );

      ++number;

      sItr = mapFilenamesUsed.find( alternateName );
    } while( sItr != mapFilenamesUsed.end() );

    printWarning( "Map name %s already used, using %s instead.\n",
                  mapNameInOutputFiles.data(),
                  alternateName.data() );

    mapNameInOutputFiles.assign( alternateName );
  }

  mapFilenamesUsed.insert( mapNameInOutputFiles );
}