Why does the compiler yield an error when I declared the parameter a char and used a char argument in htoi?Assigning a value to a variable in a chain in JavaHow to solve casting warning in creating MessageBoxWhy does a function with no parameters (compared to the actual function definition) compile?Why typecasting between char *ptr to int and int *ptr to char works completely fine? when they are designed to point to specific datatyped variablesWhy dynamically allocated memory of a function parameter is lost when exiting the function?How to add a char/int to an char array in C?casting int pointer to char pointerMaking integer from a pointer without a castHigh Order and Low-order byteassignment makes integer from pointer without a cast (C language.)While executing this program the char function does the returning the variable.i dont know why?
Oath of redemption: Does Emmissary of Peace reflect damage taken from Aura of the Guardian?
Should students have access to past exams or an exam bank?
If the Moon were impacted by a suitably sized meteor, how long would it take to impact the Earth?
How to prevent a single-element caster from being useless against immune foes?
Why don't short runways use ramps for takeoff?
Were there any unmanned expeditions to the moon that returned to Earth prior to Apollo?
If I buy and download a game through second Nintendo account do I own it on my main account too?
A coworker mumbles to herself when working. How can I ask her to stop?
How do I safety check that there is no light in Darkroom / Darkbag?
How to count points under the curve?
"Will flex for food". What does this phrase mean?
Applying for mortgage when living together but only one will be on the mortgage
What is my clock telling me to do?
How to delete a line from a variable?
How to crop this photo of water drops on a leaf to improve the composition?
Backpacking with incontinence
UX writing: When to use "we"?
Why have both: BJT and FET transistors on IC output?
Why do MS SQL Server SEQUENCEs not have an ORDER parameter like Oracle?
describing weighing an object in hand
Should I put my name first or last in the team members list?
Is Norway in the Single Market?
Why is the "I" in "Indigenous crisis" capitalized?
A game of red and black
Why does the compiler yield an error when I declared the parameter a char and used a char argument in htoi?
Assigning a value to a variable in a chain in JavaHow to solve casting warning in creating MessageBoxWhy does a function with no parameters (compared to the actual function definition) compile?Why typecasting between char *ptr to int and int *ptr to char works completely fine? when they are designed to point to specific datatyped variablesWhy dynamically allocated memory of a function parameter is lost when exiting the function?How to add a char/int to an char array in C?casting int pointer to char pointerMaking integer from a pointer without a castHigh Order and Low-order byteassignment makes integer from pointer without a cast (C language.)While executing this program the char function does the returning the variable.i dont know why?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm writing a program that converts hexadecimal values to the number digit value, to that end I've made it so the integer function htoi(char s[i]) accepts char arrays.
I plug in a char array using getchar() to allow the user to input characters which then get assigned to an array in my code, and said array is then used as the argument of htoi, however the compiler complains that htoi is using an argument with a pointer without a cast and wants char.
I've tried changing the arrays like char s[] to int s[i], because a char is just a smaller int, right? So, when I change it to int, the compiler then complains that htoi{s[i]) (s[] being an int now) makes a pointer from integer without a cast.
So, I realize that an iterator within an array is nothing but a pointer to an element within the array, okay. Great, so I remove I and. . . It expects an expression before ']' token.
I've exhausted my toolkit.
#include <stdio.h>
#define YES 1
#define NO 0
#define EXIT '~'
int htoi(int s[]);
int main()
int i, c = 0;
int s[i];
for (i = 0; (c = getchar()!= EXIT); i++) c == ' ')
htoi(s[]);
else
putchar(c);
int htoi(int s[])
int isHexidecimal;
int hexdigit;
int n;
int i = 0;
if(s[i] == '0')
i++;
if(s[i] == 'x'
isHexidecimal = YES;
while(isHexidecimal == YES)
if(s[i] >= '0' && s[i] <= 9)
hexdigit += s[i] - '0';
i++;
else if(s[i] >= 'a' && s[i] <= 'f')
hexdigit += s[i] - 'a' + 10;
i++;
else if(s[i] >= 'A' && s[i] <= 'F')
hexdigit += s[i] - 'A' + 10;
i++;
else
isHexidecimal = NO;
if(isHexidecimal == YES)
n = n * 16 + hexdigit;
else
n += 0;
return n;
I expect the main method to run the getchar() function which is assigned to variable c, and then assign variable c to the array, then pass said array onto htoi.
htoi would return the hexadecimal to integer value, or '0' if I have not entered a valid hexadecimal value, or returns the hexadecimal value and terminates as a result of the loop not having a valid hexadecimal value entered.
c
|
show 2 more comments
I'm writing a program that converts hexadecimal values to the number digit value, to that end I've made it so the integer function htoi(char s[i]) accepts char arrays.
I plug in a char array using getchar() to allow the user to input characters which then get assigned to an array in my code, and said array is then used as the argument of htoi, however the compiler complains that htoi is using an argument with a pointer without a cast and wants char.
I've tried changing the arrays like char s[] to int s[i], because a char is just a smaller int, right? So, when I change it to int, the compiler then complains that htoi{s[i]) (s[] being an int now) makes a pointer from integer without a cast.
So, I realize that an iterator within an array is nothing but a pointer to an element within the array, okay. Great, so I remove I and. . . It expects an expression before ']' token.
I've exhausted my toolkit.
#include <stdio.h>
#define YES 1
#define NO 0
#define EXIT '~'
int htoi(int s[]);
int main()
int i, c = 0;
int s[i];
for (i = 0; (c = getchar()!= EXIT); i++) c == ' ')
htoi(s[]);
else
putchar(c);
int htoi(int s[])
int isHexidecimal;
int hexdigit;
int n;
int i = 0;
if(s[i] == '0')
i++;
if(s[i] == 'x'
isHexidecimal = YES;
while(isHexidecimal == YES)
if(s[i] >= '0' && s[i] <= 9)
hexdigit += s[i] - '0';
i++;
else if(s[i] >= 'a' && s[i] <= 'f')
hexdigit += s[i] - 'a' + 10;
i++;
else if(s[i] >= 'A' && s[i] <= 'F')
hexdigit += s[i] - 'A' + 10;
i++;
else
isHexidecimal = NO;
if(isHexidecimal == YES)
n = n * 16 + hexdigit;
else
n += 0;
return n;
I expect the main method to run the getchar() function which is assigned to variable c, and then assign variable c to the array, then pass said array onto htoi.
htoi would return the hexadecimal to integer value, or '0' if I have not entered a valid hexadecimal value, or returns the hexadecimal value and terminates as a result of the loop not having a valid hexadecimal value entered.
c
int i, c = 0; int s[i];Sinceihas no particular value,int s[i];tries to declare an array with no particular size. Ouch.
– David Schwartz
Mar 26 at 23:00
OOF. cough Thanks, David-San. Alright, but I'm curious. Why does this trick work in Java but not in C? The chaining of assignments? I'm learning C through the C programming Language book 2nd edition, so some things are a little lost on me here.
– Matthew_J_Barnes
Mar 26 at 23:15
Where is the chain in "i,c = 0" ? It's not "i = c = 0" as in stackoverflow.com/questions/13116833/… ... Only the "int" is kept with the , it doesn't try to assign to a tuple!
– B. Go
Mar 27 at 0:21
So you need to set a max size to s, check it in the for loop (or risk a buffer overflow), and your current code won't work correctly for a second value input after one of your 3 separators. Actually as your string never ends with a , I'm not sure it will work even for the first value!
– B. Go
Mar 27 at 0:25
Or any other valid stopping condition, as you're not using a string... Right now you parse uninitialized memory, it could contain anything after your value's chars
– B. Go
Mar 27 at 0:28
|
show 2 more comments
I'm writing a program that converts hexadecimal values to the number digit value, to that end I've made it so the integer function htoi(char s[i]) accepts char arrays.
I plug in a char array using getchar() to allow the user to input characters which then get assigned to an array in my code, and said array is then used as the argument of htoi, however the compiler complains that htoi is using an argument with a pointer without a cast and wants char.
I've tried changing the arrays like char s[] to int s[i], because a char is just a smaller int, right? So, when I change it to int, the compiler then complains that htoi{s[i]) (s[] being an int now) makes a pointer from integer without a cast.
So, I realize that an iterator within an array is nothing but a pointer to an element within the array, okay. Great, so I remove I and. . . It expects an expression before ']' token.
I've exhausted my toolkit.
#include <stdio.h>
#define YES 1
#define NO 0
#define EXIT '~'
int htoi(int s[]);
int main()
int i, c = 0;
int s[i];
for (i = 0; (c = getchar()!= EXIT); i++) c == ' ')
htoi(s[]);
else
putchar(c);
int htoi(int s[])
int isHexidecimal;
int hexdigit;
int n;
int i = 0;
if(s[i] == '0')
i++;
if(s[i] == 'x'
isHexidecimal = YES;
while(isHexidecimal == YES)
if(s[i] >= '0' && s[i] <= 9)
hexdigit += s[i] - '0';
i++;
else if(s[i] >= 'a' && s[i] <= 'f')
hexdigit += s[i] - 'a' + 10;
i++;
else if(s[i] >= 'A' && s[i] <= 'F')
hexdigit += s[i] - 'A' + 10;
i++;
else
isHexidecimal = NO;
if(isHexidecimal == YES)
n = n * 16 + hexdigit;
else
n += 0;
return n;
I expect the main method to run the getchar() function which is assigned to variable c, and then assign variable c to the array, then pass said array onto htoi.
htoi would return the hexadecimal to integer value, or '0' if I have not entered a valid hexadecimal value, or returns the hexadecimal value and terminates as a result of the loop not having a valid hexadecimal value entered.
c
I'm writing a program that converts hexadecimal values to the number digit value, to that end I've made it so the integer function htoi(char s[i]) accepts char arrays.
I plug in a char array using getchar() to allow the user to input characters which then get assigned to an array in my code, and said array is then used as the argument of htoi, however the compiler complains that htoi is using an argument with a pointer without a cast and wants char.
I've tried changing the arrays like char s[] to int s[i], because a char is just a smaller int, right? So, when I change it to int, the compiler then complains that htoi{s[i]) (s[] being an int now) makes a pointer from integer without a cast.
So, I realize that an iterator within an array is nothing but a pointer to an element within the array, okay. Great, so I remove I and. . . It expects an expression before ']' token.
I've exhausted my toolkit.
#include <stdio.h>
#define YES 1
#define NO 0
#define EXIT '~'
int htoi(int s[]);
int main()
int i, c = 0;
int s[i];
for (i = 0; (c = getchar()!= EXIT); i++) c == ' ')
htoi(s[]);
else
putchar(c);
int htoi(int s[])
int isHexidecimal;
int hexdigit;
int n;
int i = 0;
if(s[i] == '0')
i++;
if(s[i] == 'x'
isHexidecimal = YES;
while(isHexidecimal == YES)
if(s[i] >= '0' && s[i] <= 9)
hexdigit += s[i] - '0';
i++;
else if(s[i] >= 'a' && s[i] <= 'f')
hexdigit += s[i] - 'a' + 10;
i++;
else if(s[i] >= 'A' && s[i] <= 'F')
hexdigit += s[i] - 'A' + 10;
i++;
else
isHexidecimal = NO;
if(isHexidecimal == YES)
n = n * 16 + hexdigit;
else
n += 0;
return n;
I expect the main method to run the getchar() function which is assigned to variable c, and then assign variable c to the array, then pass said array onto htoi.
htoi would return the hexadecimal to integer value, or '0' if I have not entered a valid hexadecimal value, or returns the hexadecimal value and terminates as a result of the loop not having a valid hexadecimal value entered.
c
c
asked Mar 26 at 22:48
Matthew_J_BarnesMatthew_J_Barnes
237 bronze badges
237 bronze badges
int i, c = 0; int s[i];Sinceihas no particular value,int s[i];tries to declare an array with no particular size. Ouch.
– David Schwartz
Mar 26 at 23:00
OOF. cough Thanks, David-San. Alright, but I'm curious. Why does this trick work in Java but not in C? The chaining of assignments? I'm learning C through the C programming Language book 2nd edition, so some things are a little lost on me here.
– Matthew_J_Barnes
Mar 26 at 23:15
Where is the chain in "i,c = 0" ? It's not "i = c = 0" as in stackoverflow.com/questions/13116833/… ... Only the "int" is kept with the , it doesn't try to assign to a tuple!
– B. Go
Mar 27 at 0:21
So you need to set a max size to s, check it in the for loop (or risk a buffer overflow), and your current code won't work correctly for a second value input after one of your 3 separators. Actually as your string never ends with a , I'm not sure it will work even for the first value!
– B. Go
Mar 27 at 0:25
Or any other valid stopping condition, as you're not using a string... Right now you parse uninitialized memory, it could contain anything after your value's chars
– B. Go
Mar 27 at 0:28
|
show 2 more comments
int i, c = 0; int s[i];Sinceihas no particular value,int s[i];tries to declare an array with no particular size. Ouch.
– David Schwartz
Mar 26 at 23:00
OOF. cough Thanks, David-San. Alright, but I'm curious. Why does this trick work in Java but not in C? The chaining of assignments? I'm learning C through the C programming Language book 2nd edition, so some things are a little lost on me here.
– Matthew_J_Barnes
Mar 26 at 23:15
Where is the chain in "i,c = 0" ? It's not "i = c = 0" as in stackoverflow.com/questions/13116833/… ... Only the "int" is kept with the , it doesn't try to assign to a tuple!
– B. Go
Mar 27 at 0:21
So you need to set a max size to s, check it in the for loop (or risk a buffer overflow), and your current code won't work correctly for a second value input after one of your 3 separators. Actually as your string never ends with a , I'm not sure it will work even for the first value!
– B. Go
Mar 27 at 0:25
Or any other valid stopping condition, as you're not using a string... Right now you parse uninitialized memory, it could contain anything after your value's chars
– B. Go
Mar 27 at 0:28
int i, c = 0; int s[i]; Since i has no particular value, int s[i]; tries to declare an array with no particular size. Ouch.– David Schwartz
Mar 26 at 23:00
int i, c = 0; int s[i]; Since i has no particular value, int s[i]; tries to declare an array with no particular size. Ouch.– David Schwartz
Mar 26 at 23:00
OOF. cough Thanks, David-San. Alright, but I'm curious. Why does this trick work in Java but not in C? The chaining of assignments? I'm learning C through the C programming Language book 2nd edition, so some things are a little lost on me here.
– Matthew_J_Barnes
Mar 26 at 23:15
OOF. cough Thanks, David-San. Alright, but I'm curious. Why does this trick work in Java but not in C? The chaining of assignments? I'm learning C through the C programming Language book 2nd edition, so some things are a little lost on me here.
– Matthew_J_Barnes
Mar 26 at 23:15
Where is the chain in "i,c = 0" ? It's not "i = c = 0" as in stackoverflow.com/questions/13116833/… ... Only the "int" is kept with the , it doesn't try to assign to a tuple!
– B. Go
Mar 27 at 0:21
Where is the chain in "i,c = 0" ? It's not "i = c = 0" as in stackoverflow.com/questions/13116833/… ... Only the "int" is kept with the , it doesn't try to assign to a tuple!
– B. Go
Mar 27 at 0:21
So you need to set a max size to s, check it in the for loop (or risk a buffer overflow), and your current code won't work correctly for a second value input after one of your 3 separators. Actually as your string never ends with a , I'm not sure it will work even for the first value!
– B. Go
Mar 27 at 0:25
So you need to set a max size to s, check it in the for loop (or risk a buffer overflow), and your current code won't work correctly for a second value input after one of your 3 separators. Actually as your string never ends with a , I'm not sure it will work even for the first value!
– B. Go
Mar 27 at 0:25
Or any other valid stopping condition, as you're not using a string... Right now you parse uninitialized memory, it could contain anything after your value's chars
– B. Go
Mar 27 at 0:28
Or any other valid stopping condition, as you're not using a string... Right now you parse uninitialized memory, it could contain anything after your value's chars
– B. Go
Mar 27 at 0:28
|
show 2 more comments
1 Answer
1
active
oldest
votes
htoi(s[]);
is invalid, it doesn't mean anything. Just pass the pointer to the array.
htoi(s);
The
int htoi(int s[]);
The array declaration int s[] inside a function parameter list int htoi( <here> ) is interpreted exactly as if it is a pointer to the type int *s
He may want to look at C11 Standard - 6.3.2.1 Other Operands - Lvalues, arrays, and function designators(p3) to figure out where the pointer you are talking about comes from.
– David C. Rankin
Mar 26 at 22:55
I understand. Since I'm bringing up an array with an iterator, it works just like an array with a pointer, and therefore it doesn't work as I had intended.
– Matthew_J_Barnes
Mar 26 at 23:16
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55367280%2fwhy-does-the-compiler-yield-an-error-when-i-declared-the-parameter-a-char-and-us%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
htoi(s[]);
is invalid, it doesn't mean anything. Just pass the pointer to the array.
htoi(s);
The
int htoi(int s[]);
The array declaration int s[] inside a function parameter list int htoi( <here> ) is interpreted exactly as if it is a pointer to the type int *s
He may want to look at C11 Standard - 6.3.2.1 Other Operands - Lvalues, arrays, and function designators(p3) to figure out where the pointer you are talking about comes from.
– David C. Rankin
Mar 26 at 22:55
I understand. Since I'm bringing up an array with an iterator, it works just like an array with a pointer, and therefore it doesn't work as I had intended.
– Matthew_J_Barnes
Mar 26 at 23:16
add a comment |
htoi(s[]);
is invalid, it doesn't mean anything. Just pass the pointer to the array.
htoi(s);
The
int htoi(int s[]);
The array declaration int s[] inside a function parameter list int htoi( <here> ) is interpreted exactly as if it is a pointer to the type int *s
He may want to look at C11 Standard - 6.3.2.1 Other Operands - Lvalues, arrays, and function designators(p3) to figure out where the pointer you are talking about comes from.
– David C. Rankin
Mar 26 at 22:55
I understand. Since I'm bringing up an array with an iterator, it works just like an array with a pointer, and therefore it doesn't work as I had intended.
– Matthew_J_Barnes
Mar 26 at 23:16
add a comment |
htoi(s[]);
is invalid, it doesn't mean anything. Just pass the pointer to the array.
htoi(s);
The
int htoi(int s[]);
The array declaration int s[] inside a function parameter list int htoi( <here> ) is interpreted exactly as if it is a pointer to the type int *s
htoi(s[]);
is invalid, it doesn't mean anything. Just pass the pointer to the array.
htoi(s);
The
int htoi(int s[]);
The array declaration int s[] inside a function parameter list int htoi( <here> ) is interpreted exactly as if it is a pointer to the type int *s
edited Mar 26 at 23:04
answered Mar 26 at 22:52
Kamil CukKamil Cuk
18.9k2 gold badges8 silver badges36 bronze badges
18.9k2 gold badges8 silver badges36 bronze badges
He may want to look at C11 Standard - 6.3.2.1 Other Operands - Lvalues, arrays, and function designators(p3) to figure out where the pointer you are talking about comes from.
– David C. Rankin
Mar 26 at 22:55
I understand. Since I'm bringing up an array with an iterator, it works just like an array with a pointer, and therefore it doesn't work as I had intended.
– Matthew_J_Barnes
Mar 26 at 23:16
add a comment |
He may want to look at C11 Standard - 6.3.2.1 Other Operands - Lvalues, arrays, and function designators(p3) to figure out where the pointer you are talking about comes from.
– David C. Rankin
Mar 26 at 22:55
I understand. Since I'm bringing up an array with an iterator, it works just like an array with a pointer, and therefore it doesn't work as I had intended.
– Matthew_J_Barnes
Mar 26 at 23:16
He may want to look at C11 Standard - 6.3.2.1 Other Operands - Lvalues, arrays, and function designators(p3) to figure out where the pointer you are talking about comes from.
– David C. Rankin
Mar 26 at 22:55
He may want to look at C11 Standard - 6.3.2.1 Other Operands - Lvalues, arrays, and function designators(p3) to figure out where the pointer you are talking about comes from.
– David C. Rankin
Mar 26 at 22:55
I understand. Since I'm bringing up an array with an iterator, it works just like an array with a pointer, and therefore it doesn't work as I had intended.
– Matthew_J_Barnes
Mar 26 at 23:16
I understand. Since I'm bringing up an array with an iterator, it works just like an array with a pointer, and therefore it doesn't work as I had intended.
– Matthew_J_Barnes
Mar 26 at 23:16
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55367280%2fwhy-does-the-compiler-yield-an-error-when-i-declared-the-parameter-a-char-and-us%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
int i, c = 0; int s[i];Sinceihas no particular value,int s[i];tries to declare an array with no particular size. Ouch.– David Schwartz
Mar 26 at 23:00
OOF. cough Thanks, David-San. Alright, but I'm curious. Why does this trick work in Java but not in C? The chaining of assignments? I'm learning C through the C programming Language book 2nd edition, so some things are a little lost on me here.
– Matthew_J_Barnes
Mar 26 at 23:15
Where is the chain in "i,c = 0" ? It's not "i = c = 0" as in stackoverflow.com/questions/13116833/… ... Only the "int" is kept with the , it doesn't try to assign to a tuple!
– B. Go
Mar 27 at 0:21
So you need to set a max size to s, check it in the for loop (or risk a buffer overflow), and your current code won't work correctly for a second value input after one of your 3 separators. Actually as your string never ends with a , I'm not sure it will work even for the first value!
– B. Go
Mar 27 at 0:25
Or any other valid stopping condition, as you're not using a string... Right now you parse uninitialized memory, it could contain anything after your value's chars
– B. Go
Mar 27 at 0:28