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

  • Context: C/C++ 
  • Thread starter Thread starter Tom McCurdy
  • Start date Start date
  • Tags Tags
    Programming
Click For Summary

Discussion Overview

The discussion revolves around troubleshooting a C++ code snippet intended to replace characters in a string between angle brackets (< >) with periods. The scope includes programming help and debugging techniques.

Discussion Character

  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant describes a loop intended to convert characters between < > to periods but notes that the entire string is being altered instead.
  • Another participant suggests that the issue may stem from using the assignment operator instead of the boolean operator in the "if" statement.
  • There is a mention of unnecessary code that may have been included for debugging purposes.
  • A participant expresses surprise at missing the error and indicates that only one problem remains after the suggested correction.

Areas of Agreement / Disagreement

Participants appear to agree on the identification of a common mistake regarding the use of operators, but the overall problem remains unresolved as the original poster still has one issue left to address.

Contextual Notes

There is a lack of clarity on the complete context of the code, as the original poster refrains from sharing the entire codebase, which may limit understanding of the problem.

Who May Find This Useful

Individuals seeking assistance with C++ programming, particularly those dealing with string manipulation and debugging techniques.

Tom McCurdy
Messages
1,021
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:
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
Replies
12
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 14 ·
Replies
14
Views
35K