![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| char data type i am going to develop a program will read data from a file that contains #s, simple spaces, digits and new line characters. in the program i am going to use while ((ch = getchar()) != EOF). when i declare the ch, it must be in type char or i can use type int? due to the digits part eventually i need to store them into 2-d array and use them as a number for operation. please advise what is the best and simple way to get on. thanks in advance. |
| |
| |||
| well, the code was trying to open a file called test.txt. if it opens successfully, then it copies all the contents from the file to the variable x. variable sum then holds the number of character being copied and display the number of characters. the sum and x variable declare as type int, but in the file test.txt does it contain all kinds of character? that means i can declare variable ch as type int, according to my question above, if you output to type int variable, it can also work for input to type int variable. am i correct? but as i mentioned my test.txt apart from digit numbers, it has '#' character, simple spaces and new line character. as type int variable still can work with these characters is that right? |
![]() |
| Thread Tools | |
| Display Modes | |
| |