I'm writing a C program on visual studio. But my program doesn't run nor it returns any errors. Can someone...
I hopelessly tried to copy paste this into another file but it still doesn't return anything.
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "conio.h"
#pragma warning (disable: 4996)
typedef struct item
{
char *pName;
int Quantity, Price, Total;
} ITEM;
ITEM *Exam(char *pInput);
int main()
{
ITEM *pItem;
char input[81];
printf("Type items: ");
gets_s(input);
char *pInput = input;
pItem = Exam(pInput);
printf("Name: %snQuantity: %dnPrice: %dnTotal: %dn", pItem->pName, pItem->Quantity, pItem->Price, pItem->Total);
free(pItem);
return 0;
}
ITEM *Exam(char *pInput)
{
ITEM *pItem = (ITEM *)malloc(sizeof(ITEM));
char *pNam, *pQuantity, *pPrice;
int total, l, q, p;
int qu, pr;
for (l = 0; *(pInput + l) != ','; l++);
pNam = (char *)malloc(l + 1);
*(pInput + l) = '';
strcpy(pNam, pInput);
pItem->pName = pNam;
*(pInput + l) = ',';
for (q = 0; *(pInput + l + 2 + q) != ','; q++);
pQuantity = (char *)malloc(q + 1);
*(pInput + l + q + 2) = 0;
strcpy(pQuantity, pInput + l + 2);
qu = atoi(pQuantity);
pItem->Quantity = qu;
for (p = 0; *(pInput + l + q + 4) != ';' || *(pInput + l + q + 4) != 0; p++);
pPrice = (char *)malloc(p + 1);
*(pInput + l + q + 4) = 0;
strcpy(pPrice, pInput + l + q + 4);
pr = atoi(pPrice);
pItem->Price = pr;
pItem->Total = pr * qu;
return pItem;
}
input is 'shirt, 100, 5'. I want the output to be a structure of name, quantity, price and total. It let me type the input but when i press enter it doesn't return anything. The program just hangs...
c visual-studio
|
show 10 more comments
I hopelessly tried to copy paste this into another file but it still doesn't return anything.
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "conio.h"
#pragma warning (disable: 4996)
typedef struct item
{
char *pName;
int Quantity, Price, Total;
} ITEM;
ITEM *Exam(char *pInput);
int main()
{
ITEM *pItem;
char input[81];
printf("Type items: ");
gets_s(input);
char *pInput = input;
pItem = Exam(pInput);
printf("Name: %snQuantity: %dnPrice: %dnTotal: %dn", pItem->pName, pItem->Quantity, pItem->Price, pItem->Total);
free(pItem);
return 0;
}
ITEM *Exam(char *pInput)
{
ITEM *pItem = (ITEM *)malloc(sizeof(ITEM));
char *pNam, *pQuantity, *pPrice;
int total, l, q, p;
int qu, pr;
for (l = 0; *(pInput + l) != ','; l++);
pNam = (char *)malloc(l + 1);
*(pInput + l) = '';
strcpy(pNam, pInput);
pItem->pName = pNam;
*(pInput + l) = ',';
for (q = 0; *(pInput + l + 2 + q) != ','; q++);
pQuantity = (char *)malloc(q + 1);
*(pInput + l + q + 2) = 0;
strcpy(pQuantity, pInput + l + 2);
qu = atoi(pQuantity);
pItem->Quantity = qu;
for (p = 0; *(pInput + l + q + 4) != ';' || *(pInput + l + q + 4) != 0; p++);
pPrice = (char *)malloc(p + 1);
*(pInput + l + q + 4) = 0;
strcpy(pPrice, pInput + l + q + 4);
pr = atoi(pPrice);
pItem->Price = pr;
pItem->Total = pr * qu;
return pItem;
}
input is 'shirt, 100, 5'. I want the output to be a structure of name, quantity, price and total. It let me type the input but when i press enter it doesn't return anything. The program just hangs...
c visual-studio
1
First of all, why don't you use the standardstrtok
function? Secondly, I suggest you learn how to debug your programs. Especially how to run inside the debugger and how to catch crashes (which might be what you have).
– Some programmer dude
Jan 1 at 16:52
Where does it hang? (Attach a debugger.)
– Davis Herring
Jan 1 at 16:53
@Davis Herring after i type the input and hit enter. it doesn't do anything. It just stays there
– catify
Jan 1 at 16:54
2
You should edit the question rather than clarify in comments. The question says that it does not run, when it clearly does if it prompts for input. VS has about the best debugger available - consider using it; it will be far faster that posting questions on SO.
– Clifford
Jan 1 at 17:38
1
@catify to use all these offsets complicate a lot your program, it is more simple to have a pointer going through the string, just my 2 cents
– bruno
Jan 1 at 17:45
|
show 10 more comments
I hopelessly tried to copy paste this into another file but it still doesn't return anything.
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "conio.h"
#pragma warning (disable: 4996)
typedef struct item
{
char *pName;
int Quantity, Price, Total;
} ITEM;
ITEM *Exam(char *pInput);
int main()
{
ITEM *pItem;
char input[81];
printf("Type items: ");
gets_s(input);
char *pInput = input;
pItem = Exam(pInput);
printf("Name: %snQuantity: %dnPrice: %dnTotal: %dn", pItem->pName, pItem->Quantity, pItem->Price, pItem->Total);
free(pItem);
return 0;
}
ITEM *Exam(char *pInput)
{
ITEM *pItem = (ITEM *)malloc(sizeof(ITEM));
char *pNam, *pQuantity, *pPrice;
int total, l, q, p;
int qu, pr;
for (l = 0; *(pInput + l) != ','; l++);
pNam = (char *)malloc(l + 1);
*(pInput + l) = '';
strcpy(pNam, pInput);
pItem->pName = pNam;
*(pInput + l) = ',';
for (q = 0; *(pInput + l + 2 + q) != ','; q++);
pQuantity = (char *)malloc(q + 1);
*(pInput + l + q + 2) = 0;
strcpy(pQuantity, pInput + l + 2);
qu = atoi(pQuantity);
pItem->Quantity = qu;
for (p = 0; *(pInput + l + q + 4) != ';' || *(pInput + l + q + 4) != 0; p++);
pPrice = (char *)malloc(p + 1);
*(pInput + l + q + 4) = 0;
strcpy(pPrice, pInput + l + q + 4);
pr = atoi(pPrice);
pItem->Price = pr;
pItem->Total = pr * qu;
return pItem;
}
input is 'shirt, 100, 5'. I want the output to be a structure of name, quantity, price and total. It let me type the input but when i press enter it doesn't return anything. The program just hangs...
c visual-studio
I hopelessly tried to copy paste this into another file but it still doesn't return anything.
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "conio.h"
#pragma warning (disable: 4996)
typedef struct item
{
char *pName;
int Quantity, Price, Total;
} ITEM;
ITEM *Exam(char *pInput);
int main()
{
ITEM *pItem;
char input[81];
printf("Type items: ");
gets_s(input);
char *pInput = input;
pItem = Exam(pInput);
printf("Name: %snQuantity: %dnPrice: %dnTotal: %dn", pItem->pName, pItem->Quantity, pItem->Price, pItem->Total);
free(pItem);
return 0;
}
ITEM *Exam(char *pInput)
{
ITEM *pItem = (ITEM *)malloc(sizeof(ITEM));
char *pNam, *pQuantity, *pPrice;
int total, l, q, p;
int qu, pr;
for (l = 0; *(pInput + l) != ','; l++);
pNam = (char *)malloc(l + 1);
*(pInput + l) = '';
strcpy(pNam, pInput);
pItem->pName = pNam;
*(pInput + l) = ',';
for (q = 0; *(pInput + l + 2 + q) != ','; q++);
pQuantity = (char *)malloc(q + 1);
*(pInput + l + q + 2) = 0;
strcpy(pQuantity, pInput + l + 2);
qu = atoi(pQuantity);
pItem->Quantity = qu;
for (p = 0; *(pInput + l + q + 4) != ';' || *(pInput + l + q + 4) != 0; p++);
pPrice = (char *)malloc(p + 1);
*(pInput + l + q + 4) = 0;
strcpy(pPrice, pInput + l + q + 4);
pr = atoi(pPrice);
pItem->Price = pr;
pItem->Total = pr * qu;
return pItem;
}
input is 'shirt, 100, 5'. I want the output to be a structure of name, quantity, price and total. It let me type the input but when i press enter it doesn't return anything. The program just hangs...
c visual-studio
c visual-studio
asked Jan 1 at 16:49
catifycatify
156
156
1
First of all, why don't you use the standardstrtok
function? Secondly, I suggest you learn how to debug your programs. Especially how to run inside the debugger and how to catch crashes (which might be what you have).
– Some programmer dude
Jan 1 at 16:52
Where does it hang? (Attach a debugger.)
– Davis Herring
Jan 1 at 16:53
@Davis Herring after i type the input and hit enter. it doesn't do anything. It just stays there
– catify
Jan 1 at 16:54
2
You should edit the question rather than clarify in comments. The question says that it does not run, when it clearly does if it prompts for input. VS has about the best debugger available - consider using it; it will be far faster that posting questions on SO.
– Clifford
Jan 1 at 17:38
1
@catify to use all these offsets complicate a lot your program, it is more simple to have a pointer going through the string, just my 2 cents
– bruno
Jan 1 at 17:45
|
show 10 more comments
1
First of all, why don't you use the standardstrtok
function? Secondly, I suggest you learn how to debug your programs. Especially how to run inside the debugger and how to catch crashes (which might be what you have).
– Some programmer dude
Jan 1 at 16:52
Where does it hang? (Attach a debugger.)
– Davis Herring
Jan 1 at 16:53
@Davis Herring after i type the input and hit enter. it doesn't do anything. It just stays there
– catify
Jan 1 at 16:54
2
You should edit the question rather than clarify in comments. The question says that it does not run, when it clearly does if it prompts for input. VS has about the best debugger available - consider using it; it will be far faster that posting questions on SO.
– Clifford
Jan 1 at 17:38
1
@catify to use all these offsets complicate a lot your program, it is more simple to have a pointer going through the string, just my 2 cents
– bruno
Jan 1 at 17:45
1
1
First of all, why don't you use the standard
strtok
function? Secondly, I suggest you learn how to debug your programs. Especially how to run inside the debugger and how to catch crashes (which might be what you have).– Some programmer dude
Jan 1 at 16:52
First of all, why don't you use the standard
strtok
function? Secondly, I suggest you learn how to debug your programs. Especially how to run inside the debugger and how to catch crashes (which might be what you have).– Some programmer dude
Jan 1 at 16:52
Where does it hang? (Attach a debugger.)
– Davis Herring
Jan 1 at 16:53
Where does it hang? (Attach a debugger.)
– Davis Herring
Jan 1 at 16:53
@Davis Herring after i type the input and hit enter. it doesn't do anything. It just stays there
– catify
Jan 1 at 16:54
@Davis Herring after i type the input and hit enter. it doesn't do anything. It just stays there
– catify
Jan 1 at 16:54
2
2
You should edit the question rather than clarify in comments. The question says that it does not run, when it clearly does if it prompts for input. VS has about the best debugger available - consider using it; it will be far faster that posting questions on SO.
– Clifford
Jan 1 at 17:38
You should edit the question rather than clarify in comments. The question says that it does not run, when it clearly does if it prompts for input. VS has about the best debugger available - consider using it; it will be far faster that posting questions on SO.
– Clifford
Jan 1 at 17:38
1
1
@catify to use all these offsets complicate a lot your program, it is more simple to have a pointer going through the string, just my 2 cents
– bruno
Jan 1 at 17:45
@catify to use all these offsets complicate a lot your program, it is more simple to have a pointer going through the string, just my 2 cents
– bruno
Jan 1 at 17:45
|
show 10 more comments
1 Answer
1
active
oldest
votes
The last for in Exam is :
for (p = 0; *(pInput + l + q + 4) != ';' || *(pInput + l + q + 4) != 0; p++);
that for never end because its condition is always true
- if
*(pInput + l + q + 4)
values ';' the test isfalse || true
then true - if
*(pInput + l + q + 4)
values 0 the test istrue || false
then true - for all the other characters the test is
true || true
so again true
+ 4
must be+ 3
else goes 1 character too far- and
p++
has no effect at all on the test
The test can be changed to !(*(pInput + l + q + 3 + p) == ';' || *(pInput + l + q + 3 + p) == 0)
to stop when ';' or the null character is reached
Of course after *(pInput + l + q + 4) = 0;
must be *(pInput + l + q + 3 + p) = 0;
Note that pQuantity
and pPrice
are allocated but never freed.
Exam can be simplified, for instance :
ITEM *Exam(const char *pInput)
{
ITEM *pItem = (ITEM *)malloc(sizeof(ITEM));
const char *p;
p = strchr(pInput, ',');
pItem->pName = strndup(pInput, p - pInput);
p += 1;
pItem->Quantity = atoi(p);
p = strchr(p, ',') + 1;
pItem->Price = atoi(p);
pItem->Total = pItem->Price * pItem->Quantity;
return pItem;
}
Note that the input string is not modified (I moved it const
) and there is no dynamic allocation except for the result and the name
if you do not have strndup :
char * strndup(const char * s, int n)
{
char * r = (char *) malloc(n + 1);
memcpy(r, s, n);
r[n] = 0;
return r;
}
Thank you so much for your time and knowledge sir!
– catify
Jan 2 at 14:21
@catify I added strndup if you don't have it on visual-studio, and I added a missing const in the declaration of p
– bruno
Jan 2 at 14:36
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%2f53997234%2fim-writing-a-c-program-on-visual-studio-but-my-program-doesnt-run-nor-it-retu%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
The last for in Exam is :
for (p = 0; *(pInput + l + q + 4) != ';' || *(pInput + l + q + 4) != 0; p++);
that for never end because its condition is always true
- if
*(pInput + l + q + 4)
values ';' the test isfalse || true
then true - if
*(pInput + l + q + 4)
values 0 the test istrue || false
then true - for all the other characters the test is
true || true
so again true
+ 4
must be+ 3
else goes 1 character too far- and
p++
has no effect at all on the test
The test can be changed to !(*(pInput + l + q + 3 + p) == ';' || *(pInput + l + q + 3 + p) == 0)
to stop when ';' or the null character is reached
Of course after *(pInput + l + q + 4) = 0;
must be *(pInput + l + q + 3 + p) = 0;
Note that pQuantity
and pPrice
are allocated but never freed.
Exam can be simplified, for instance :
ITEM *Exam(const char *pInput)
{
ITEM *pItem = (ITEM *)malloc(sizeof(ITEM));
const char *p;
p = strchr(pInput, ',');
pItem->pName = strndup(pInput, p - pInput);
p += 1;
pItem->Quantity = atoi(p);
p = strchr(p, ',') + 1;
pItem->Price = atoi(p);
pItem->Total = pItem->Price * pItem->Quantity;
return pItem;
}
Note that the input string is not modified (I moved it const
) and there is no dynamic allocation except for the result and the name
if you do not have strndup :
char * strndup(const char * s, int n)
{
char * r = (char *) malloc(n + 1);
memcpy(r, s, n);
r[n] = 0;
return r;
}
Thank you so much for your time and knowledge sir!
– catify
Jan 2 at 14:21
@catify I added strndup if you don't have it on visual-studio, and I added a missing const in the declaration of p
– bruno
Jan 2 at 14:36
add a comment |
The last for in Exam is :
for (p = 0; *(pInput + l + q + 4) != ';' || *(pInput + l + q + 4) != 0; p++);
that for never end because its condition is always true
- if
*(pInput + l + q + 4)
values ';' the test isfalse || true
then true - if
*(pInput + l + q + 4)
values 0 the test istrue || false
then true - for all the other characters the test is
true || true
so again true
+ 4
must be+ 3
else goes 1 character too far- and
p++
has no effect at all on the test
The test can be changed to !(*(pInput + l + q + 3 + p) == ';' || *(pInput + l + q + 3 + p) == 0)
to stop when ';' or the null character is reached
Of course after *(pInput + l + q + 4) = 0;
must be *(pInput + l + q + 3 + p) = 0;
Note that pQuantity
and pPrice
are allocated but never freed.
Exam can be simplified, for instance :
ITEM *Exam(const char *pInput)
{
ITEM *pItem = (ITEM *)malloc(sizeof(ITEM));
const char *p;
p = strchr(pInput, ',');
pItem->pName = strndup(pInput, p - pInput);
p += 1;
pItem->Quantity = atoi(p);
p = strchr(p, ',') + 1;
pItem->Price = atoi(p);
pItem->Total = pItem->Price * pItem->Quantity;
return pItem;
}
Note that the input string is not modified (I moved it const
) and there is no dynamic allocation except for the result and the name
if you do not have strndup :
char * strndup(const char * s, int n)
{
char * r = (char *) malloc(n + 1);
memcpy(r, s, n);
r[n] = 0;
return r;
}
Thank you so much for your time and knowledge sir!
– catify
Jan 2 at 14:21
@catify I added strndup if you don't have it on visual-studio, and I added a missing const in the declaration of p
– bruno
Jan 2 at 14:36
add a comment |
The last for in Exam is :
for (p = 0; *(pInput + l + q + 4) != ';' || *(pInput + l + q + 4) != 0; p++);
that for never end because its condition is always true
- if
*(pInput + l + q + 4)
values ';' the test isfalse || true
then true - if
*(pInput + l + q + 4)
values 0 the test istrue || false
then true - for all the other characters the test is
true || true
so again true
+ 4
must be+ 3
else goes 1 character too far- and
p++
has no effect at all on the test
The test can be changed to !(*(pInput + l + q + 3 + p) == ';' || *(pInput + l + q + 3 + p) == 0)
to stop when ';' or the null character is reached
Of course after *(pInput + l + q + 4) = 0;
must be *(pInput + l + q + 3 + p) = 0;
Note that pQuantity
and pPrice
are allocated but never freed.
Exam can be simplified, for instance :
ITEM *Exam(const char *pInput)
{
ITEM *pItem = (ITEM *)malloc(sizeof(ITEM));
const char *p;
p = strchr(pInput, ',');
pItem->pName = strndup(pInput, p - pInput);
p += 1;
pItem->Quantity = atoi(p);
p = strchr(p, ',') + 1;
pItem->Price = atoi(p);
pItem->Total = pItem->Price * pItem->Quantity;
return pItem;
}
Note that the input string is not modified (I moved it const
) and there is no dynamic allocation except for the result and the name
if you do not have strndup :
char * strndup(const char * s, int n)
{
char * r = (char *) malloc(n + 1);
memcpy(r, s, n);
r[n] = 0;
return r;
}
The last for in Exam is :
for (p = 0; *(pInput + l + q + 4) != ';' || *(pInput + l + q + 4) != 0; p++);
that for never end because its condition is always true
- if
*(pInput + l + q + 4)
values ';' the test isfalse || true
then true - if
*(pInput + l + q + 4)
values 0 the test istrue || false
then true - for all the other characters the test is
true || true
so again true
+ 4
must be+ 3
else goes 1 character too far- and
p++
has no effect at all on the test
The test can be changed to !(*(pInput + l + q + 3 + p) == ';' || *(pInput + l + q + 3 + p) == 0)
to stop when ';' or the null character is reached
Of course after *(pInput + l + q + 4) = 0;
must be *(pInput + l + q + 3 + p) = 0;
Note that pQuantity
and pPrice
are allocated but never freed.
Exam can be simplified, for instance :
ITEM *Exam(const char *pInput)
{
ITEM *pItem = (ITEM *)malloc(sizeof(ITEM));
const char *p;
p = strchr(pInput, ',');
pItem->pName = strndup(pInput, p - pInput);
p += 1;
pItem->Quantity = atoi(p);
p = strchr(p, ',') + 1;
pItem->Price = atoi(p);
pItem->Total = pItem->Price * pItem->Quantity;
return pItem;
}
Note that the input string is not modified (I moved it const
) and there is no dynamic allocation except for the result and the name
if you do not have strndup :
char * strndup(const char * s, int n)
{
char * r = (char *) malloc(n + 1);
memcpy(r, s, n);
r[n] = 0;
return r;
}
edited Jan 2 at 14:32
answered Jan 1 at 17:10
brunobruno
10.1k21126
10.1k21126
Thank you so much for your time and knowledge sir!
– catify
Jan 2 at 14:21
@catify I added strndup if you don't have it on visual-studio, and I added a missing const in the declaration of p
– bruno
Jan 2 at 14:36
add a comment |
Thank you so much for your time and knowledge sir!
– catify
Jan 2 at 14:21
@catify I added strndup if you don't have it on visual-studio, and I added a missing const in the declaration of p
– bruno
Jan 2 at 14:36
Thank you so much for your time and knowledge sir!
– catify
Jan 2 at 14:21
Thank you so much for your time and knowledge sir!
– catify
Jan 2 at 14:21
@catify I added strndup if you don't have it on visual-studio, and I added a missing const in the declaration of p
– bruno
Jan 2 at 14:36
@catify I added strndup if you don't have it on visual-studio, and I added a missing const in the declaration of p
– bruno
Jan 2 at 14:36
add a comment |
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%2f53997234%2fim-writing-a-c-program-on-visual-studio-but-my-program-doesnt-run-nor-it-retu%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
1
First of all, why don't you use the standard
strtok
function? Secondly, I suggest you learn how to debug your programs. Especially how to run inside the debugger and how to catch crashes (which might be what you have).– Some programmer dude
Jan 1 at 16:52
Where does it hang? (Attach a debugger.)
– Davis Herring
Jan 1 at 16:53
@Davis Herring after i type the input and hit enter. it doesn't do anything. It just stays there
– catify
Jan 1 at 16:54
2
You should edit the question rather than clarify in comments. The question says that it does not run, when it clearly does if it prompts for input. VS has about the best debugger available - consider using it; it will be far faster that posting questions on SO.
– Clifford
Jan 1 at 17:38
1
@catify to use all these offsets complicate a lot your program, it is more simple to have a pointer going through the string, just my 2 cents
– bruno
Jan 1 at 17:45