Coder Social home page Coder Social logo

strrev missing?? about md_parola HOT 7 CLOSED

Guenni75 avatar Guenni75 commented on June 21, 2024
strrev missing??

from md_parola.

Comments (7)

MajicDesigns avatar MajicDesigns commented on June 21, 2024

The strrev() function (used to reverse the given string) is a built-in function in C and is defined in string.h header file, which is a standard header file for all C++ compilers.

Please check that you have string.h on your computer.

What development environment are you using?

from md_parola.

Guenni75 avatar Guenni75 commented on June 21, 2024

I work with the Arduino IDE 2.0.3.

from md_parola.

MajicDesigns avatar MajicDesigns commented on June 21, 2024

IDE 2.0.3 under Windows 10 with target Arduino Uno compiles cleanly on my system.

from md_parola.

Guenni75 avatar Guenni75 commented on June 21, 2024

I compile with a WEMOS D1 (esp8266).
The problem is, strrev is no standard C library function.

image

from md_parola.

Guenni75 avatar Guenni75 commented on June 21, 2024

I tried to reverse the Array by myself.
I changed BUF_SIZE to 7.

image

The Serialmonitor shows everything is ok, BUT
I don't understand, why is reverseMessage empty??????
And newMessage is an Array! Why can i print it so simple with Serial.print ???

If i skip the reverse action, the LCD works.

from md_parola.

MajicDesigns avatar MajicDesigns commented on June 21, 2024

Your reverse function is logically flawed. The string is generally not the size of the buffer (so you should use strlen() not BUF_SIZE) and you are not handling the terminating nul character properly in the reversal process. The standard strrev() does the reverse in the same buffer (ie, no additional memory required).

Here is the code for the strrev() function from the libraries:

void strrev(unsigned char *str)
{
  int i;
  int j;
  unsigned char a;
  unsigned int len = strlen((const char *)str);
   
  for (i = 0, j = len - 1; i < j; i++, j--)
  {
  a = str[i];
  str[i] = str[j];
  str[j] = a;
  }
}

Also, for future reference, please include text and not graphics when including code or debug output in your messages as these are easier to handle if we need to cut/paste for testing.

from md_parola.

Guenni75 avatar Guenni75 commented on June 21, 2024

Thanks.
I will try this.

from md_parola.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.