replace function. which header file ?

This is a discussion on replace function. which header file ? within the C++ Programming forums, part of the General Programming Boards category; Seems to be in <iostream> but i have that referenced and am still getting a 384 `Replace' undeclared (first use ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    91

    replace function. which header file ?

    Seems to be in <iostream> but i have that referenced and am still getting a

    384 `Replace' undeclared (first use this function)

  2. #2
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    <algorithm>, if you're talking about 'replace' (not 'Replace').

  3. #3
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    there's also a replace function in <string>

    I very highly recommend this resource: http://www.cppreference.com/index.html
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  4. #4
    Registered User
    Join Date
    Jun 2003
    Posts
    91
    Quote Originally Posted by Rashakil Fol
    <algorithm>, if you're talking about 'replace' (not 'Replace').

    Its Replace, does that mean it a custom function ?. Also, this probably a bit newb but my algorithm 'header' is just a file no extension ?

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    91
    Argg...

    I need a function that will replace a string with function in the form.

    Replace(strString,".",",");


    any ideas ?

  6. #6
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446
    I'm not sure, what is the value in strString, and what do you expect the output to be?
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

  7. #7
    Registered User
    Join Date
    Jun 2003
    Posts
    91
    For example char strString = "hello,world"

    Replace(strString,",",".")

    would yield,

    hello.world

    So

    replace(charater(s),find character(s),replace with)

    .

  8. #8
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    that'd be the one in <algorithm>:
    Code:
    #include <iostream>
    #include <algorithm>
    #include <string>
    
    int main()
    {
    	std::string s1="Hello,World";
    	std::cout<<"Original: "<<s1;
    	replace(s1.begin(),s1.end(),',',' ');
    	std::cout<<"\nNew: "<<s1<<std::endl;
    	return 0;
    }
    output:
    Code:
    Original: Hello,World
    New: Hello World
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 07:54 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 05:14 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  5. Header file for "fix" function ?
    By Rex in forum C++ Programming
    Replies: 1
    Last Post: 04-08-2003, 05:42 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21