Error involving fgetc() function












0














After execution I get the following errors:



Thread 1: signal SIGABRT
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)



What can it be?



#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_USERNAME 10
#define MAX_PASSWORD 15
#define MIN_USERNAME 3
#define MIN_PASSWORD 3
#define MIN_AGE 18
#define MAX_AGE 100
#define MIN_LOGIN_INFO 3
#define MAX_INFO 211
#define MAX_HOBBIES 4
#define MAX 10
#define ID_LENGTH 9
#define NAME_LENGTH 15
#define NAME_LENGTH 15
#define DESCRIPTION 211


void skip3(FILE *input,char* getInput);
void skip4(FILE *input,char* getInput);

int main(){
char id[ID_LENGTH];
char name[MAX_PASSWORD], surname[MAX_PASSWORD], username[MAX_USERNAME],
password[MAX_PASSWORD], description[MAX_INFO], hobbies[MAX_HOBBIES], gender[MIN_LOGIN_INFO],age[MIN_LOGIN_INFO];
FILE *input=NULL;
int cChar=0;


input = fopen("input.txt","r");
if(input == NULL){
exit(1);
}
cChar=fgetc(input);
rewind(input);
while(cChar != EOF){
skip3(input,id);
skip3(input,name);
skip3(input,surname);
skip3(input,age);
skip3(input,gender);
skip3(input,username);
skip3(input,password);
skip3(input,hobbies);
skip4(input,description);
printf("Sent to listn");
cChar=fgetc(input);
}
printf("end");
fclose(input);
printf("end");

return 0;
}



void skip3(FILE *input,char* getInput){
int r;
int currentChar=0;
int index=0;

currentChar = (char)currentChar;
while(currentChar != ';'){
currentChar = fgetc(input);
index++;
currentChar = (char)currentChar;
}
r=fseek(input, -(index), SEEK_CUR);
fgets(getInput,index,input);
r=fseek(input, 1, SEEK_CUR);


}
void skip4(FILE *input,char* getInput){
int currentChar=0;
int index=0;
int i=0;
int r;

currentChar = (char)currentChar;
while(currentChar != 'r'){
currentChar = fgetc(input);
index++;
currentChar = (char)currentChar;
if(currentChar == EOF){
break;
}
}
currentChar = (char)currentChar;
if(currentChar == EOF){
i=1;
}
r=fseek(input, -(index-i), SEEK_CUR);
currentChar = (char)currentChar;
fgets(getInput,index,input);
if(currentChar != EOF){
r=fseek(input, 2, SEEK_CUR);
}


}









share|improve this question







New contributor




gbox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • If your code is not working, try stackoverflow. This site is for reviewing working code.
    – Artyer
    4 mins ago
















0














After execution I get the following errors:



Thread 1: signal SIGABRT
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)



What can it be?



#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_USERNAME 10
#define MAX_PASSWORD 15
#define MIN_USERNAME 3
#define MIN_PASSWORD 3
#define MIN_AGE 18
#define MAX_AGE 100
#define MIN_LOGIN_INFO 3
#define MAX_INFO 211
#define MAX_HOBBIES 4
#define MAX 10
#define ID_LENGTH 9
#define NAME_LENGTH 15
#define NAME_LENGTH 15
#define DESCRIPTION 211


void skip3(FILE *input,char* getInput);
void skip4(FILE *input,char* getInput);

int main(){
char id[ID_LENGTH];
char name[MAX_PASSWORD], surname[MAX_PASSWORD], username[MAX_USERNAME],
password[MAX_PASSWORD], description[MAX_INFO], hobbies[MAX_HOBBIES], gender[MIN_LOGIN_INFO],age[MIN_LOGIN_INFO];
FILE *input=NULL;
int cChar=0;


input = fopen("input.txt","r");
if(input == NULL){
exit(1);
}
cChar=fgetc(input);
rewind(input);
while(cChar != EOF){
skip3(input,id);
skip3(input,name);
skip3(input,surname);
skip3(input,age);
skip3(input,gender);
skip3(input,username);
skip3(input,password);
skip3(input,hobbies);
skip4(input,description);
printf("Sent to listn");
cChar=fgetc(input);
}
printf("end");
fclose(input);
printf("end");

return 0;
}



void skip3(FILE *input,char* getInput){
int r;
int currentChar=0;
int index=0;

currentChar = (char)currentChar;
while(currentChar != ';'){
currentChar = fgetc(input);
index++;
currentChar = (char)currentChar;
}
r=fseek(input, -(index), SEEK_CUR);
fgets(getInput,index,input);
r=fseek(input, 1, SEEK_CUR);


}
void skip4(FILE *input,char* getInput){
int currentChar=0;
int index=0;
int i=0;
int r;

currentChar = (char)currentChar;
while(currentChar != 'r'){
currentChar = fgetc(input);
index++;
currentChar = (char)currentChar;
if(currentChar == EOF){
break;
}
}
currentChar = (char)currentChar;
if(currentChar == EOF){
i=1;
}
r=fseek(input, -(index-i), SEEK_CUR);
currentChar = (char)currentChar;
fgets(getInput,index,input);
if(currentChar != EOF){
r=fseek(input, 2, SEEK_CUR);
}


}









share|improve this question







New contributor




gbox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • If your code is not working, try stackoverflow. This site is for reviewing working code.
    – Artyer
    4 mins ago














0












0








0







After execution I get the following errors:



Thread 1: signal SIGABRT
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)



What can it be?



#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_USERNAME 10
#define MAX_PASSWORD 15
#define MIN_USERNAME 3
#define MIN_PASSWORD 3
#define MIN_AGE 18
#define MAX_AGE 100
#define MIN_LOGIN_INFO 3
#define MAX_INFO 211
#define MAX_HOBBIES 4
#define MAX 10
#define ID_LENGTH 9
#define NAME_LENGTH 15
#define NAME_LENGTH 15
#define DESCRIPTION 211


void skip3(FILE *input,char* getInput);
void skip4(FILE *input,char* getInput);

int main(){
char id[ID_LENGTH];
char name[MAX_PASSWORD], surname[MAX_PASSWORD], username[MAX_USERNAME],
password[MAX_PASSWORD], description[MAX_INFO], hobbies[MAX_HOBBIES], gender[MIN_LOGIN_INFO],age[MIN_LOGIN_INFO];
FILE *input=NULL;
int cChar=0;


input = fopen("input.txt","r");
if(input == NULL){
exit(1);
}
cChar=fgetc(input);
rewind(input);
while(cChar != EOF){
skip3(input,id);
skip3(input,name);
skip3(input,surname);
skip3(input,age);
skip3(input,gender);
skip3(input,username);
skip3(input,password);
skip3(input,hobbies);
skip4(input,description);
printf("Sent to listn");
cChar=fgetc(input);
}
printf("end");
fclose(input);
printf("end");

return 0;
}



void skip3(FILE *input,char* getInput){
int r;
int currentChar=0;
int index=0;

currentChar = (char)currentChar;
while(currentChar != ';'){
currentChar = fgetc(input);
index++;
currentChar = (char)currentChar;
}
r=fseek(input, -(index), SEEK_CUR);
fgets(getInput,index,input);
r=fseek(input, 1, SEEK_CUR);


}
void skip4(FILE *input,char* getInput){
int currentChar=0;
int index=0;
int i=0;
int r;

currentChar = (char)currentChar;
while(currentChar != 'r'){
currentChar = fgetc(input);
index++;
currentChar = (char)currentChar;
if(currentChar == EOF){
break;
}
}
currentChar = (char)currentChar;
if(currentChar == EOF){
i=1;
}
r=fseek(input, -(index-i), SEEK_CUR);
currentChar = (char)currentChar;
fgets(getInput,index,input);
if(currentChar != EOF){
r=fseek(input, 2, SEEK_CUR);
}


}









share|improve this question







New contributor




gbox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











After execution I get the following errors:



Thread 1: signal SIGABRT
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)



What can it be?



#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_USERNAME 10
#define MAX_PASSWORD 15
#define MIN_USERNAME 3
#define MIN_PASSWORD 3
#define MIN_AGE 18
#define MAX_AGE 100
#define MIN_LOGIN_INFO 3
#define MAX_INFO 211
#define MAX_HOBBIES 4
#define MAX 10
#define ID_LENGTH 9
#define NAME_LENGTH 15
#define NAME_LENGTH 15
#define DESCRIPTION 211


void skip3(FILE *input,char* getInput);
void skip4(FILE *input,char* getInput);

int main(){
char id[ID_LENGTH];
char name[MAX_PASSWORD], surname[MAX_PASSWORD], username[MAX_USERNAME],
password[MAX_PASSWORD], description[MAX_INFO], hobbies[MAX_HOBBIES], gender[MIN_LOGIN_INFO],age[MIN_LOGIN_INFO];
FILE *input=NULL;
int cChar=0;


input = fopen("input.txt","r");
if(input == NULL){
exit(1);
}
cChar=fgetc(input);
rewind(input);
while(cChar != EOF){
skip3(input,id);
skip3(input,name);
skip3(input,surname);
skip3(input,age);
skip3(input,gender);
skip3(input,username);
skip3(input,password);
skip3(input,hobbies);
skip4(input,description);
printf("Sent to listn");
cChar=fgetc(input);
}
printf("end");
fclose(input);
printf("end");

return 0;
}



void skip3(FILE *input,char* getInput){
int r;
int currentChar=0;
int index=0;

currentChar = (char)currentChar;
while(currentChar != ';'){
currentChar = fgetc(input);
index++;
currentChar = (char)currentChar;
}
r=fseek(input, -(index), SEEK_CUR);
fgets(getInput,index,input);
r=fseek(input, 1, SEEK_CUR);


}
void skip4(FILE *input,char* getInput){
int currentChar=0;
int index=0;
int i=0;
int r;

currentChar = (char)currentChar;
while(currentChar != 'r'){
currentChar = fgetc(input);
index++;
currentChar = (char)currentChar;
if(currentChar == EOF){
break;
}
}
currentChar = (char)currentChar;
if(currentChar == EOF){
i=1;
}
r=fseek(input, -(index-i), SEEK_CUR);
currentChar = (char)currentChar;
fgets(getInput,index,input);
if(currentChar != EOF){
r=fseek(input, 2, SEEK_CUR);
}


}






c file






share|improve this question







New contributor




gbox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




gbox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




gbox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 18 mins ago









gbox

1011




1011




New contributor




gbox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





gbox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






gbox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • If your code is not working, try stackoverflow. This site is for reviewing working code.
    – Artyer
    4 mins ago


















  • If your code is not working, try stackoverflow. This site is for reviewing working code.
    – Artyer
    4 mins ago
















If your code is not working, try stackoverflow. This site is for reviewing working code.
– Artyer
4 mins ago




If your code is not working, try stackoverflow. This site is for reviewing working code.
– Artyer
4 mins ago















active

oldest

votes











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");

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: "196"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});


}
});






gbox is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f210735%2ferror-involving-fgetc-function%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








gbox is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















gbox is a new contributor. Be nice, and check out our Code of Conduct.













gbox is a new contributor. Be nice, and check out our Code of Conduct.












gbox is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Code Review Stack Exchange!


  • 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.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f210735%2ferror-involving-fgetc-function%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Morgemoulin

Scott Moir

Souastre