Click here to Skip to main content
15,169,508 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: error: expected identifier before string constant Pin
Vaclav_14-Jan-19 4:33
MemberVaclav_14-Jan-19 4:33 
GeneralRe: error: expected identifier before string constant Pin
Graham Breach14-Jan-19 5:33
MemberGraham Breach14-Jan-19 5:33 
AnswerRe: error: expected identifier before string constant Pin
Stefan_Lang16-Jan-19 23:38
mveStefan_Lang16-Jan-19 23:38 
GeneralRe: error: expected identifier before string constant Pin
Vaclav_19-Jan-19 19:31
MemberVaclav_19-Jan-19 19:31 
Question(C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student11-Jan-19 4:27
MemberHS_C_Student11-Jan-19 4:27 
AnswerRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
CPallini11-Jan-19 6:25
mveCPallini11-Jan-19 6:25 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
Bram van Kampen12-Jan-19 15:29
MemberBram van Kampen12-Jan-19 15:29 
SuggestionRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
David Crow11-Jan-19 6:40
MemberDavid Crow11-Jan-19 6:40 
Member 14088880 wrote:

So implicitly an unsigned int is not capable of an access violation Below / before an array's first element given the pointer arithmetic. All that being said it does not seem at all necessary to test it.
If your function looked something like:
void myfunction(int array[], unsigned int count)
{
    for (unsigned x = 0; x < count; x++)
        ...
}
Then it is possible to call it like:
myfunction(array, -1);
which would result in the for() loop running for a very long time.

"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


GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student11-Jan-19 8:17
MemberHS_C_Student11-Jan-19 8:17 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
David Crow11-Jan-19 8:33
MemberDavid Crow11-Jan-19 8:33 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
Joe Woodbury11-Jan-19 12:54
professionalJoe Woodbury11-Jan-19 12:54 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student11-Jan-19 13:18
MemberHS_C_Student11-Jan-19 13:18 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
leon de boer12-Jan-19 4:36
Memberleon de boer12-Jan-19 4:36 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student12-Jan-19 5:59
MemberHS_C_Student12-Jan-19 5:59 
AnswerRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
Bram van Kampen12-Jan-19 15:01
MemberBram van Kampen12-Jan-19 15:01 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student12-Jan-19 17:50
MemberHS_C_Student12-Jan-19 17:50 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
Richard MacCutchan12-Jan-19 23:51
mveRichard MacCutchan12-Jan-19 23:51 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student13-Jan-19 8:10
MemberHS_C_Student13-Jan-19 8:10 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
Richard MacCutchan13-Jan-19 23:12
mveRichard MacCutchan13-Jan-19 23:12 
AnswerDemonstrating the relevant case and potential best practice Pin
HS_C_Student13-Jan-19 7:46
MemberHS_C_Student13-Jan-19 7:46 
GeneralRe: Demonstrating the relevant case and potential best practice Pin
Richard MacCutchan13-Jan-19 23:15
mveRichard MacCutchan13-Jan-19 23:15 
AnswerRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
Stefan_Lang17-Jan-19 0:13
mveStefan_Lang17-Jan-19 0:13 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student17-Jan-19 14:05
MemberHS_C_Student17-Jan-19 14:05 
Questionacademic question - usage of class variable Pin
Vaclav_10-Jan-19 6:20
MemberVaclav_10-Jan-19 6:20 
AnswerRe: academic question - usage of class variable Pin
Richard MacCutchan10-Jan-19 7:27
mveRichard MacCutchan10-Jan-19 7:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.