Hello,
I've pretty much finished this programming assignment, but I've hit a very strange, but small, snag. It's a pretty simple program: it takes a single word as an argument, prints the output of the 'banner' command with that word, then prints the negative of banner's output. Here's an example:
Code:
stephen> ./negbanner hello
Original banner output:
# # ####### # # #######
# # # # # # #
# # # # # # #
####### ##### # # # #
# # # # # # #
# # # # # # #
# # ####### ####### ####### #######
Negative of banner output:
%%%%% %% %% %%%%%%%% %%%%%%%% %%
%%%%% %% %%%%%%%% %%%%%%%% %%%%%%%% %%%%% %%
%%%%% %% %%%%%%%% %%%%%%%% %%%%%%%% %%%%% %%
%% %%%% %%%%%%%% %%%%%%%% %%%%% %%
%%%%% %% %%%%%%%% %%%%%%%% %%%%%%%% %%%%% %%
%%%%% %% %%%%%%%% %%%%%%%% %%%%%%%% %%%%% %%
%%%%% %% %% %% %% %%
Of course you'll notice that the negative is made up of '%'s instead of '#'; therein lies my problem. The code that writes the '%'s looks like this:
Code:
if (bann_file[curr] == ' ')
bann_file[curr] = '%';
Here, bann_file is a pointer to the temporary file, which is a shared file mapping via mmap() (the overwriting is done by child processes; one per line). So it's basically just a char*. And this obviously works fine. But when I change '%' to '#' I get this:
Code:
stephen> ./negbanner hello
Original banner output:
# # ####### # # #######
# # # # # # #
# # # # # # #
####### ##### # # # #
# # # # # # #
# # # # # # #
# # ####### ####### ####### #######
Negative of banner output:
stephen>
I've tried redirecting the output to separate text files, and after running wc on them, it looks like the outputs contain the exact same number of characters, so the characters are all there, but something's getting lost in translation. Obviously '#' is a special character in C, but it's not escapable; I've also tried using the ASCII code directly (35), but I get the same result. Anyone happen to know what may be going on?
I can provide more info on the implementation if need be, but seeing as how it works with other characters I'd be surprised if that were needed. Thanks.