Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. const char [] and char[] difference question

const char [] and char[] difference question

Scheduled Pinned Locked Moved C / C++ / MFC
hardwarehelpquestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    focusdoit
    wrote on last edited by
    #1

    Hi, I wrote a small c program on a microcontroller, 32bit. I met a weird problem. I wrote code like:

    const char strtest[] = "Test123\r\n"; //Global
    UART_print(strtest); //in a loop

    the output is fine, I can see the output on Teraterm(RS232 interface tool), like: Test123 Test123 .. But when I try code:

    char str123[] = "Test123\r\n"; //Global
    UART_print(strtest); //in a loop

    The output is only the first element: TTTTTTTT Any hint is appreciated.

    D L V 3 Replies Last reply
    0
    • F focusdoit

      Hi, I wrote a small c program on a microcontroller, 32bit. I met a weird problem. I wrote code like:

      const char strtest[] = "Test123\r\n"; //Global
      UART_print(strtest); //in a loop

      the output is fine, I can see the output on Teraterm(RS232 interface tool), like: Test123 Test123 .. But when I try code:

      char str123[] = "Test123\r\n"; //Global
      UART_print(strtest); //in a loop

      The output is only the first element: TTTTTTTT Any hint is appreciated.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      focusdoit wrote:

      char str123[] = "Test123\r\n"; //Global UART_print(strtest); //in a loop

      Where is str123 used? What is the signature of UART_print()?

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

      1 Reply Last reply
      0
      • F focusdoit

        Hi, I wrote a small c program on a microcontroller, 32bit. I met a weird problem. I wrote code like:

        const char strtest[] = "Test123\r\n"; //Global
        UART_print(strtest); //in a loop

        the output is fine, I can see the output on Teraterm(RS232 interface tool), like: Test123 Test123 .. But when I try code:

        char str123[] = "Test123\r\n"; //Global
        UART_print(strtest); //in a loop

        The output is only the first element: TTTTTTTT Any hint is appreciated.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Please show the code for the UART_print function.

        1 Reply Last reply
        0
        • F focusdoit

          Hi, I wrote a small c program on a microcontroller, 32bit. I met a weird problem. I wrote code like:

          const char strtest[] = "Test123\r\n"; //Global
          UART_print(strtest); //in a loop

          the output is fine, I can see the output on Teraterm(RS232 interface tool), like: Test123 Test123 .. But when I try code:

          char str123[] = "Test123\r\n"; //Global
          UART_print(strtest); //in a loop

          The output is only the first element: TTTTTTTT Any hint is appreciated.

          V Offline
          V Offline
          Victor Nijegorodov
          wrote on last edited by
          #4

          focusdoit wrote:

          But when I try code:

          char str123[] = "Test123\r\n"; //Global
          UART_print(strtest); //in a loop

          You defined the variable str123 but you print the strtest. Where and how is this strtest defined?

          S 1 Reply Last reply
          0
          • V Victor Nijegorodov

            focusdoit wrote:

            But when I try code:

            char str123[] = "Test123\r\n"; //Global
            UART_print(strtest); //in a loop

            You defined the variable str123 but you print the strtest. Where and how is this strtest defined?

            S Offline
            S Offline
            samzcs
            wrote on last edited by
            #5

            It's memory allocation problem. the MCU has 2 cpu inside, and one set of peripheral units, compiler put str123 in DMA Access prohibited area. Embedded programming, too many tricks. :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups