473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Confusing error ?!?!

im working on a prgm to do LZW compression

In a file I stored a character with the code: 26(binary:00011010) when I try to retreive the code from the file I get the int value -1 and(binary:11111111111111111111111111111111), why is that!??! Is it possible to get the character code 26 back from the file it was stored in?

I know the character value is 26 definitely but using getc() doesnt give me the correct value back. Also that the character code 26 represents SUB (no idea).

#include <iostream.h>
#include <stdio.h>

void main()
{
FILE *input=fopen("1.txt","r");

cout << "\n(getc(input): " << (int) getc(input);

fclose(input);

}

Jul 22 '05 #1
2 953
* "dwaonng" <dw*********@yahoo.com> schriebt:

im working on a prgm to do LZW compression

In a file I stored a character with the code: 26(binary:00011010)
when I try to retreive the code from the file I get the int value -1
and(binary:11111111111111111111111111111111), why is that!??!
That's a feature of the compiler, library and/or operating system you're
using (for example, in MS-DOS a Ctrl Z marks end-of-file for a text file),
which standard C++ very unfortunately not only allows but encourages --
give me a whip and the committee members, and I'll whip 'em for you, very
enthusiastically.

To avoid this problem use binary file mode, not text mode.

Is it possible to get the character code 26 back from the file it
was stored in?


Yes.

Jul 22 '05 #2
Hi. I was wondering if there were any good tutorials related to socket
programming, and handling different protocols, etc.

Thanks,

J.L.
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David MacQuigg | last post by:
I'm setting up a large hierarchy of module packages and using a variable to select which of many alternative packages to import. For example, the variable 'config.modsel' points to a particular...
65
by: Pmb | last post by:
I'm confused as to what the compiler error message I'm getting is refering to. Can someone take a gander and let me know what I did wrong? The program is below. When I compile it I get the...
16
by: Shelly | last post by:
(posted previously on comp.lang.php but no response received. Cross-posted in the dreamweaver forum) I am confused about what goes on with method POST. Here is an overview of a my code,...
2
by: d3vkit | last post by:
Okay so I can NOT get my while loop to work. It's the most confusing thing I've ever come across. It was working fine and then suddenly, nothing. No error. The page just dies. I am using PHP5 with...
12
by: Wilson | last post by:
Hi, while writing a simplified version of a program i created the following class, however when i went to compile and run the program there was an error saying "multiple types in one...
1
by: Nyx18 | last post by:
ok so i got my class to work now im having confusing errors with this: void sort(Student stu, int parameter, int count) { Student temp; bool finished = false; while (!finished) ...
7
by: Luna Moon | last post by:
Hi all, I just couldn't get myself clear about the usage of "const" in front of and/or behind variables, pointers, classes, objects and functions... It's too confusing... any good clear...
0
by: Lloyd Sheen | last post by:
In design view of an aspx page I have an Ajax Toolkit ToolkitScriptManager control. The markup for this is <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"...
2
by: new2c | last post by:
Hi - I'm completely new to C and trying to read some code that doesn't make sense to me. For proprietary reasons I can't display the code here but I'll describe it...and list part of it in a generic...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.