Getting the ASCII value of escape sequence character from 2 chars [on hold]
up vote
-3
down vote
favorite
I'm reading chars from a file and whenever I read a char with value of 092
that is ''
I want to read this char and the next char as one and get their ascii value, is that possible?
e.g. if I read ''
and the next char is 'n'
I want to be able to get the value 010
.
I'm getting chars in while using a while
cycle and char c = fgetc(source)
.
c
New contributor
put on hold as too broad by hyde, Jean-François Fabre, Govind Parmar, Broman, OldProgrammer Nov 21 at 20:04
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-3
down vote
favorite
I'm reading chars from a file and whenever I read a char with value of 092
that is ''
I want to read this char and the next char as one and get their ascii value, is that possible?
e.g. if I read ''
and the next char is 'n'
I want to be able to get the value 010
.
I'm getting chars in while using a while
cycle and char c = fgetc(source)
.
c
New contributor
put on hold as too broad by hyde, Jean-François Fabre, Govind Parmar, Broman, OldProgrammer Nov 21 at 20:04
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
of course that's possible. By storing the fact that you encountered and a switch/case on the next char read.
– Jean-François Fabre
Nov 21 at 20:00
1
Yes, it is possible. Many ways to do it. You should try something first, snd then askfor help with that, when you run into an actual problem. One way to go about this would be to have variable for current and previous char, and play with them. Another could be to just have a bool flag telling if previous char was your escape char . Or something else.
– hyde
Nov 21 at 20:01
Give it a try and if you don't get it working, then show your code, what you have tried and what does not (yet) work correctly. (Minimal, Complete, and Verifiable example)
– Werner Henze
Nov 21 at 20:07
In C,92
is not the character back-slash (ASCII 92).digit
begins an octal-escape-sequence, not decimal. You need to post the code you have used - next time, rather than only describe the problem.
– chux
Nov 21 at 22:04
n is used in some programming languages and some types of configuration files and some types of documents (e.g. JSON). Are you writing a lexer? Surely there is one already for whatever type of file you are reading. You also need a complete list of the escapes you want to support.
– Tom Blodget
Nov 22 at 0:57
add a comment |
up vote
-3
down vote
favorite
up vote
-3
down vote
favorite
I'm reading chars from a file and whenever I read a char with value of 092
that is ''
I want to read this char and the next char as one and get their ascii value, is that possible?
e.g. if I read ''
and the next char is 'n'
I want to be able to get the value 010
.
I'm getting chars in while using a while
cycle and char c = fgetc(source)
.
c
New contributor
I'm reading chars from a file and whenever I read a char with value of 092
that is ''
I want to read this char and the next char as one and get their ascii value, is that possible?
e.g. if I read ''
and the next char is 'n'
I want to be able to get the value 010
.
I'm getting chars in while using a while
cycle and char c = fgetc(source)
.
c
c
New contributor
New contributor
New contributor
asked Nov 21 at 19:55
Jan Vaculik
1
1
New contributor
New contributor
put on hold as too broad by hyde, Jean-François Fabre, Govind Parmar, Broman, OldProgrammer Nov 21 at 20:04
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as too broad by hyde, Jean-François Fabre, Govind Parmar, Broman, OldProgrammer Nov 21 at 20:04
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
of course that's possible. By storing the fact that you encountered and a switch/case on the next char read.
– Jean-François Fabre
Nov 21 at 20:00
1
Yes, it is possible. Many ways to do it. You should try something first, snd then askfor help with that, when you run into an actual problem. One way to go about this would be to have variable for current and previous char, and play with them. Another could be to just have a bool flag telling if previous char was your escape char . Or something else.
– hyde
Nov 21 at 20:01
Give it a try and if you don't get it working, then show your code, what you have tried and what does not (yet) work correctly. (Minimal, Complete, and Verifiable example)
– Werner Henze
Nov 21 at 20:07
In C,92
is not the character back-slash (ASCII 92).digit
begins an octal-escape-sequence, not decimal. You need to post the code you have used - next time, rather than only describe the problem.
– chux
Nov 21 at 22:04
n is used in some programming languages and some types of configuration files and some types of documents (e.g. JSON). Are you writing a lexer? Surely there is one already for whatever type of file you are reading. You also need a complete list of the escapes you want to support.
– Tom Blodget
Nov 22 at 0:57
add a comment |
1
of course that's possible. By storing the fact that you encountered and a switch/case on the next char read.
– Jean-François Fabre
Nov 21 at 20:00
1
Yes, it is possible. Many ways to do it. You should try something first, snd then askfor help with that, when you run into an actual problem. One way to go about this would be to have variable for current and previous char, and play with them. Another could be to just have a bool flag telling if previous char was your escape char . Or something else.
– hyde
Nov 21 at 20:01
Give it a try and if you don't get it working, then show your code, what you have tried and what does not (yet) work correctly. (Minimal, Complete, and Verifiable example)
– Werner Henze
Nov 21 at 20:07
In C,92
is not the character back-slash (ASCII 92).digit
begins an octal-escape-sequence, not decimal. You need to post the code you have used - next time, rather than only describe the problem.
– chux
Nov 21 at 22:04
n is used in some programming languages and some types of configuration files and some types of documents (e.g. JSON). Are you writing a lexer? Surely there is one already for whatever type of file you are reading. You also need a complete list of the escapes you want to support.
– Tom Blodget
Nov 22 at 0:57
1
1
of course that's possible. By storing the fact that you encountered and a switch/case on the next char read.
– Jean-François Fabre
Nov 21 at 20:00
of course that's possible. By storing the fact that you encountered and a switch/case on the next char read.
– Jean-François Fabre
Nov 21 at 20:00
1
1
Yes, it is possible. Many ways to do it. You should try something first, snd then askfor help with that, when you run into an actual problem. One way to go about this would be to have variable for current and previous char, and play with them. Another could be to just have a bool flag telling if previous char was your escape char . Or something else.
– hyde
Nov 21 at 20:01
Yes, it is possible. Many ways to do it. You should try something first, snd then askfor help with that, when you run into an actual problem. One way to go about this would be to have variable for current and previous char, and play with them. Another could be to just have a bool flag telling if previous char was your escape char . Or something else.
– hyde
Nov 21 at 20:01
Give it a try and if you don't get it working, then show your code, what you have tried and what does not (yet) work correctly. (Minimal, Complete, and Verifiable example)
– Werner Henze
Nov 21 at 20:07
Give it a try and if you don't get it working, then show your code, what you have tried and what does not (yet) work correctly. (Minimal, Complete, and Verifiable example)
– Werner Henze
Nov 21 at 20:07
In C,
92
is not the character back-slash (ASCII 92). digit
begins an octal-escape-sequence, not decimal. You need to post the code you have used - next time, rather than only describe the problem.– chux
Nov 21 at 22:04
In C,
92
is not the character back-slash (ASCII 92). digit
begins an octal-escape-sequence, not decimal. You need to post the code you have used - next time, rather than only describe the problem.– chux
Nov 21 at 22:04
n is used in some programming languages and some types of configuration files and some types of documents (e.g. JSON). Are you writing a lexer? Surely there is one already for whatever type of file you are reading. You also need a complete list of the escapes you want to support.
– Tom Blodget
Nov 22 at 0:57
n is used in some programming languages and some types of configuration files and some types of documents (e.g. JSON). Are you writing a lexer? Surely there is one already for whatever type of file you are reading. You also need a complete list of the escapes you want to support.
– Tom Blodget
Nov 22 at 0:57
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
1
of course that's possible. By storing the fact that you encountered and a switch/case on the next char read.
– Jean-François Fabre
Nov 21 at 20:00
1
Yes, it is possible. Many ways to do it. You should try something first, snd then askfor help with that, when you run into an actual problem. One way to go about this would be to have variable for current and previous char, and play with them. Another could be to just have a bool flag telling if previous char was your escape char . Or something else.
– hyde
Nov 21 at 20:01
Give it a try and if you don't get it working, then show your code, what you have tried and what does not (yet) work correctly. (Minimal, Complete, and Verifiable example)
– Werner Henze
Nov 21 at 20:07
In C,
92
is not the character back-slash (ASCII 92).digit
begins an octal-escape-sequence, not decimal. You need to post the code you have used - next time, rather than only describe the problem.– chux
Nov 21 at 22:04
n is used in some programming languages and some types of configuration files and some types of documents (e.g. JSON). Are you writing a lexer? Surely there is one already for whatever type of file you are reading. You also need a complete list of the escapes you want to support.
– Tom Blodget
Nov 22 at 0:57