1 Replies - 408 Views - Last Post: 30 August 2019 - 12:17 PM Rate Topic: -----

#1 SC0TTii   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 17-August 19

Not a code issue, but an issue with my understanding. NEED HELP.

Posted 30 August 2019 - 11:04 AM

So i'm a beginner with programming in general, and I don't understand what the difference is by putting in "[]" vs not putting the brackets in. I was just hoping someone could clear it up for me.

Let me tell you what I think it means, and someone can tell me if I am wrong (which is most likely the case.)

I think the pointer within the parameters is pointing to whatever array we pass in it (the first element of the array that is, because it only knows it's a string but not a string array.) But my confusing is: why can I not include the "[]"? Is there some sort of significant issue with it? All help is appreciated and I posted the link to both images below.


Link:
https://imgur.com/a/fi8uSP9

Is This A Good Question/Topic? 0
  • +

Replies To: Not a code issue, but an issue with my understanding. NEED HELP.

#2 jimblumberg   User is offline

  • member icon

Reputation: 5745
  • View blog
  • Posts: 17,601
  • Joined: 25-December 09

Re: Not a code issue, but an issue with my understanding. NEED HELP.

Posted 30 August 2019 - 12:17 PM

Please cut and paste your code into a post, inside code tags.

:code:/>

The problem is really not about the brackets[] but is about the extra '*' in your second snippet.

string *someString[] is not the same as either *someString or someString[].


Edit: I suggest you start thinking about using std::vector instead of the raw arrays, they're safer and easier to understand, IMO.


Jim

This post has been edited by jimblumberg: 30 August 2019 - 12:18 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1