C/C++ C++ Programming Help: Troubleshooting "<" to ".

  • Thread starter Thread starter Tom McCurdy
  • Start date Start date
  • Tags Tags
    Programming
AI Thread Summary
The discussion revolves around a C++ code snippet intended to replace characters within angle brackets (< >) in a string with periods while leaving other characters unchanged. The user is facing an issue where the entire string is being converted to periods instead. The primary problem identified is the incorrect use of the assignment operator '=' instead of the comparison operator '==' in the conditional statements, which is a common mistake. Additionally, some parts of the code are deemed unnecessary, possibly serving only as debugging aids. The conversation also lightly touches on forum organization, noting a sub-forum for programming that could be more relevant for such discussions.
Tom McCurdy
Messages
1,017
Reaction score
1
I am having trouble with this in C++
Code:
  while(k < bodyCopy.size())
    {
      bodyCopy[k] = tolower(bodyCopy[k]);
      please=bodyCopy[k];
      cout<<please<<endl;
      if (please='<')
      {
           inTag=1;
      }
      if (inTag==1)
      {
           please='.';
           bodyCopy[k]=please;
      }
              
      if (please=='>')
      {
           inTag=0;
      }         
                                 
      
      
      k = k + 1;
    }
Its supose to replace any thing in string body.Copy between < > with periods but leave everything else alone
currently it changes everything in body.Copy to periods
any idea why??
 
Technology news on Phys.org
If it would help I would post my entire code but I have a feeling that might confuse more then help solve this problem
 
cuz you need to use the boolean operator not the assignment operator in your "if" statement, very common mistake, i hate making that error.

also some of the code seems unnecessary unless that was your debugging technique.
 
neurocomp2003 said:
cuz you need to use the boolean operator not the assignment operator in your "if" statement, very common mistake, i hate making that error.

also some of the code seems unnecessary unless that was your debugging technique.
Thank you for eyes...

I can't believe I missed that...

now only one problem left
 
I guess you must not have noticed that the next forum down, "Computers", has a sub-forum named "Programming." :smile:
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top