Program outputs strange characters

c weird characters printf
strange characters when printing pdf
pdf showing weird characters
pdf file shows junk characters
pdf printing symbols instead words
pdf characters appear as boxes
my printer is printing weird symbols

My program outputs the 4 values correctly, but adds strange characters to some of them. What am I doing wrong?

I'm not sure if the problem lies within my copy function or my print function.

Here is my copy function (I have to write my own):

char* myStrCopy(char *destination,const char *source){
   while(*source != '\0'){
    *destination = *source;

Here is my print function:

void printAllData(RentalAgency *agencies){

    RentalAgency *agencies_ptr = agencies;
    for(int i = 0; i < 3;i++,*(agencies_ptr++)){
        cout << agencies_ptr->name << " ";
        for(int j = 0; j < 5;j++){
            cout << *(agencies_ptr->zipcode+j);
        cout << endl;

        RentalCar *inv_ptr = agencies_ptr->inventory;
        for(int j = 0;j < MAX_CARS;j++,++inv_ptr){
            cout << inv_ptr->getYear() << " ";
            cout << inv_ptr->getMake() << " ";
            cout << inv_ptr->getModel() << " ";
            cout << inv_ptr->getPrice() << " ";
            cout << boolalpha << inv_ptr->getAvailability() << endl;
        cout << endl;

Here is the declaration of RentalAgency:

struct RentalAgency{
    char name[MAX_SIZE];
    int zipcode[5];
    RentalCar inventory[MAX_CARS];

The expected output of RentalArray[2] is:

Alamo 89502
2011 Toyota Rav4 $65.02 true
2012 Mazda CX5 $86.75 true
2016 Subaru Outback $71.27 false
2015 Ford F150 $112.83 true
2010 Toyota Corolla $50.36 true

But instead it outputs:

Alamo 89502
2011 ToyotaN Rav4 65.02 true
2012 Mazda CX5  86.75 true
2016 Subaru Outback 71.27 false
2015 FordÉ F15 112.83 true
2010 ToyotaÅ Corolla 50.36 true

Maybe you should modify function myStrCopy:

assert(destination!=NULL && source!=NULL);  
char* dest=destination;
while((*dest++=*source++) != '\0')
return destination;

C Programming: Weird characters in char output, There are two problems in your code: Server does not send null terminator - your code passes strlen(temp) to write(client_sock, ) , meaning that null terminator  Stack Overflow Public questions and answers; Teams Private questions and answers for your team; Enterprise Private self-hosted questions and answers for your enterprise; Jobs Programming and related technical career opportunities

Look carefully at this line:

destination = *source;

...and see if something doesn't look a bit wrong. A bit of...asymmetry. If you don't see it right away, perhaps compiling with all warnings enabled will help.

When you're done with that, you probably also want to look at:


...and think about what it does, and whether it's what you really meant to do here.

Not sure why the output is strange characters, Not sure why the output is strange characters. Thread: Not sure why the output is strange characters. Navigation. Forum · General Programming  Program output is strange characters, totally baffled I had a search round the forum and found a post explaining it could be printing the pointer value. I am not so sure about that.

The copy function stops when it hits a \0 in the source string, which means it copies everything up to but not including the \0 terminator.

A Primer on Scientific Programming with Python, You will see that there are numerous strange characters that you did not write (!). show just a small portion of all the characters in this file in the above output  Hi! I'm having a strange problem that seems to only occur on my computer running windows xp sp3, english, all updates. Always when I try to write a file with powershell strange chinese characters appear in the outputfile on random positions.

An Introduction to Java Programming and Object-Oriented , mean virtually anything to specific kinds of software or hardware. may see some recognizable characters, but you also see many other strange characters. to create binary pipelines or streams that perform input and output with binary files. Hi. I'm experiencing a strange issue with cout. What it seems to boil down to is that if I have a bunch of consecutively numbered characters output next to each other in cout, the first two are displayed incorrectly --- they show up as the venus/mars symbols (♀ and ♂), which seems to be how the display shows the ASCII values 12 and 11 respectively.

My Printer Is Printing Strange Characters, When you see garbled output or strange character substitutions on the page, put the driver software your computer uses to process output data on the top of  Find answers to Executing simple batch file outputs strange characters which break the command. from the expert community at Experts Exchange Executing simple batch file outputs strange characters which break the command.

Mastering C, The line void main() marks the beginning of the program that gets executed Notice that the message to be output is enclosed within double quotes. Note that a semicolon (;) follows ever)' statement in C. Notice the strange character pair \n  I found some very strange behavior, I tried doing the blink example. The LED was blinking before I compiled the sketch (have it plugged to pin 13 and ground). Now when I compile the sketch it compiles successfully, but changing the delay values to higher values like 5000 seems to have no effect.

  • Please, provide the complete code.
  • What is the easiest way to stop after the last letter of the source string?
  • See if you can figure it out yourself. You'll learn better than if I tell you how.
  • If i were to do it on my own I would fill the c-strings with \0, populate them then check for \0 while going through the array, however I know this is not the most efficient way.