![]() |
Skipping specific characters in files in C
Hi,
I have been trying unsuccessfully to read in a text file and skip over specific characters - something like what C++ does with cin.ignore(). I need to skip over characters like ';' and '->'. I hope someone can help me.. :nonod: |
Re: Skipping specific characters in files in C
What is the function that you use to read the text file?
Welcome to the forum :) |
Re: Skipping specific characters in files in C
I am using the fscanf function.
An example of a line from the file I am reading from is 1->2; And I want to read the 1 and 2 , ignoring the '->' and ';' And thank you so much for the welcome.. I really hope you guys can help :D |
Re: Skipping specific characters in files in C
If you use getc(), then you can check the variable and omit from your manipulation like this:
Code:
#include <stdio.h> |
Re: Skipping specific characters in files in C
thank u! You are a lifesaver! :D :happy:
|
Re: Skipping specific characters in files in C
Welcome. :)
In case your input file contains the '-' and '>' characters, they will also be omitted from reading along with the '->' symbol. I have given you an idea of how to do the skipping of characters, you should take care of the case that I mentioned here while omitting the characters. |
| All times are GMT +5.5. The time now is 00:11. |