Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9015935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:52:24+00:00 2026-06-16T03:52:24+00:00

I’m making a mfc application to make a somewhat drawing mechanism. Using a polyline

  • 0

I’m making a mfc application to make a somewhat drawing mechanism. Using a polyline the user can draw figures, and on pressing the enter key the current point of the line is joined to the starting point[to form a closed polygon]. I think you get the idea. Now, I’m using an STL array to store each vertex of the polygon- in simple words, every point at which the left-mouse button is clicked while drawing the figure is stored in the array.

std::array<CPoint,11> v;   //vertices

I’m using the following mechanism to output the elements of this array, i.e the points:

  for(int j=0 ; j<v.size() ; j++ )
    {
        s.Format(L"%d %d\n",v[j].x, v[j].y);
        aDC.TextOutW(x+=20,y+=20,s );     //each time print the coordinates
        s=" ";                                    //at a different location
    }

During execution, when the user draws the figure by clicking points around the screen, those points are stored in the array. The array’s declared with 12 elements, but rarely does a shape have 12 vertices. The rest of the element(the empty ones) remain (0,0)- and yet these are outputted in the loop. So what I get printed is 3-4 coordinates and a lots of (0,0)s. Is there a way to print only those elements in which the vertices are stored(I hope you get what I mean). Something like vertices[n]=/*some character that signifies the last element*/ . My question is, what will this character be? like a ‘\0’ in a string.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:52:25+00:00Added an answer on June 16, 2026 at 3:52 am

    It does not look like there is a good candidate for an “end marker” in a CPoint structure: every pair of {x,y} represents a legal point, at least theoretically.

    If you insist on using a fixed array (presumably, for performance reasons), you can also store the number of polygon vertices in a separate variable (continuing your string analogy, that would be a “Pascal string” of points, rather than a “C string” of points).

    If using an array is not essential, you may want to switch to a std::vector<CPoint>, a container that is better suited for representing structures of variable size, such as polygons.

    Finally, you could designate one point as illegal (say, at {std::numeric_limits<long>::max(), std::numeric_limits<long>::max()}), create an instance of that point statically, and use it as an end-of-sequence marker. In this case, consider expanding your array by one, and use the end marker as a sentinel.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.