Watch string through char pointer?

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a static struct declared in a header file, one of the members is a char array.

There's a function that returns a pointer to that array, my question is how can I watch & later use the content of the array since when passing the pointer the length information is gone.

 

char* get_open_file_name (void)
{
	return fno.fname;
}

and I use it inside main() as:

char* temp = get_open_file_name();

Currently when I add temp to the watch window I can see the ASCII value of the 1st letter of the file name (obviously).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I realized the question was related to debugging so my answer was irrelevant...

/Jakob Selbing

Last Edited: Sat. Nov 16, 2019 - 09:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

something similar to this?

https://www.avrfreaks.net/forum/...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

something similar to this?

https://www.avrfreaks.net/forum/...

 

 

So that is also not supported in Studio?!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The ,s modifier in the MSVC/AS7 debugger prints characters until 0x00 so does not need strlen as it effectively does that (handles 0x00) anyway.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, however it is not terminated.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Then for the purposes of debug do so. You can only watch "strings" with ,s if they really are strings.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or, watch it as an array of chars (even if you declare it as a pointer to chat), by adding ,n where n is the amount of chars to read...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)