Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How can I see the content of char readline[16] when debugging in QtCreator C++? [SOLVED]
Qt 6.12 LTS is out! See what's new in the release blog

How can I see the content of char readline[16] when debugging in QtCreator C++? [SOLVED]

Scheduled Pinned Locked Moved Qt Creator and other tools
14 Posts 4 Posters 11.0k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #5

    Just set a breakpoint at the line of interest. The "locals and expressions" tab of the debugger lists all variables in the current method, including the this pointer. Your readline variable should show up there. It also should have a + signe or a triangle the left, you can expand it and it shows you the contents of the array then. If you use a char * instead, it is treated as a string and the string is displayed directly.

    Find more infos about the debugger in the "respective section":http://doc.qt.nokia.com/qtcreator-2.4/creator-debugging.html of the "Qt Creator Manual":http://doc.qt.nokia.com/qtcreator-2.4/index.html.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #6

      If it was that easy I wouldn't be posting this question here :)

      In Locals and Expressions window I do have readline variable, it has a triangle, but if I click on it, it expands just nothing. I took a screenshot but I do not see how to post it here.

      [quote author="Volker" date="1327698555"]Just set a breakpoint at the line of interest. The "locals and expressions" tab of the debugger lists all variables in the current method, including the this pointer. Your readline variable should show up there. It also should have a + signe or a triangle the left, you can expand it and it shows you the contents of the array then. If you use a char * instead, it is treated as a string and the string is displayed directly.

      Find more infos about the debugger in the "respective section":http://doc.qt.nokia.com/qtcreator-2.4/creator-debugging.html of the "Qt Creator Manual":http://doc.qt.nokia.com/qtcreator-2.4/index.html.[/quote]

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #7

        On DevNet, you cannot uplaod images directly. Just use a storage provider of your choice (dropbox, flickr, picasaweb, etc. are popular).

        In my case, if I just put a

        @
        char rl[16];
        @

        The debugger shows this (I'm using Creator 2.4 on a Mac):

        !http://qdn.berlinbikerx.de/Creator-Debugger-char-array.png!

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #8

          I do not have that :(

          What I have is:

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #9

            The image is not protected, maybe some setting needs to be tweaked to make it public.

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #10

              Please check this one:

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #11

                Hm, what makes me wonder is that the type is char[] in your screenshot, whereas in mine it's char[16]. How did you declare that variable?

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #12

                  ah, good catch. However it's still a bug if it's not resolvable through some sort of setting.

                  So, if I declare it the following way then I cannot see the content:
                  int MAXLINE = 1024;
                  char sendline[MAXLINE], recvline[MAXLINE];

                  It shows the variable if I declare:
                  char sendline [1024], recvline [1024];

                  Any ideas how to resolve it?

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #13

                    I'm not 100% sure here, but I would say that allocating a static array on the stack using dynamically calculated array size, i.e. putting a variable between the brackets, is not supported by all compilers. But that's a topic for the "C++ Gurus Forum":/forums/viewforum/36/

                    Regarding Qt Creator: I would guess that it's plain just not supported here. The code model would need to know the size of the array, but that is only calculated during runtime. Creator would have to evaluate the value of the MAXLINE variable and use that for the display of the array.

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #14

                      Thank you for your help!

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt
                      • Unsolved