Thread: [URGENT] Getting warning: null character(s) ignored repeatedly

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    22

    Unhappy [URGENT] Getting warning: null character(s) ignored repeatedly

    When I compile my driver.c in MVS. It runs fine... But when I do on my schools linux machine
    after typing gcc driver.c it gives me a bunch of those messages. IE:

    Code:
    driver.c:301:169: warning: null character(s) ignored
    driver.c:301:171: warning: null character(s) ignored
    driver.c:301:173: warning: null character(s) ignored
    driver.c:301:175: warning: null character(s) ignored
    driver.c:301:177: warning: null character(s) ignored
    driver.c:301:179: warning: null character(s) ignored
    driver.c:301:181: warning: null character(s) ignored
    driver.c:301:183: warning: null character(s) ignored
    driver.c:301:185: warning: null character(s) ignored
    driver.c:302:1: warning: null character(s) ignored
    driver.c:303:1: warning: null character(s) ignored
    driver.c:303:7: warning: null character(s) ignored
    driver.c:303:9: warning: null character(s) ignored
    driver.c:303:11: warning: null character(s) ignored
    driver.c:303:13: warning: null character(s) ignored
    driver.c:303:15: warning: null character(s) ignored
    driver.c:303:17: warning: null character(s) ignored
    driver.c:303:19: warning: null character(s) ignored
    driver.c:303:20: warning: null character(s) preserved in literal
    driver.c:303:87: warning: null character(s) ignored
    driver.c:303:20: warning: unknown escape sequence: '\000'
    driver.c:303:89: warning: null character(s) ignored
    driver.c:303:93: warning: null character(s) ignored
    driver.c:303:95: warning: null character(s) ignored
    driver.c:303:97: warning: null character(s) ignored
    driver.c:303:99: warning: null character(s) ignored
    driver.c:303:101: warning: null character(s) ignored
    driver.c:303:103: warning: null character(s) ignored
    driver.c:303:105: warning: null character(s) ignored
    driver.c:303:107: warning: null character(s) ignored
    driver.c:303:109: warning: null character(s) ignored
    driver.c:303:111: warning: null character(s) ignored
    driver.c:303:113: warning: null character(s) ignored
    driver.c:303:117: warning: null character(s) ignored
    driver.c:303:119: warning: null character(s) ignored
    driver.c:303:121: warning: null character(s) ignored
    driver.c:303:123: warning: null character(s) ignored
    driver.c:303:125: warning: null character(s) ignored
    driver.c:303:127: warning: null character(s) ignored
    driver.c:303:129: warning: null character(s) ignored
    driver.c:303:131: warning: null character(s) ignored
    driver.c:303:133: warning: null character(s) ignored
    driver.c:303:135: warning: null character(s) ignored
    And keeps going... The weird thing is that my driver.c only has 165 lines...

    Plus, at the end, I get:
    driver.c:329:2: warning: no newline at end of file

    Which is not true because I checked my last line (which is 165), and it has a new line..

    Please, any help on this?
    I coded my project for 5 days straight, strees and everything
    and when I submit I get this problem... =(

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Transferring files from Windows to *nix can be interesting. Plenty of '\r' chars in there I imagine. There might be a "dos2unix" program either with your compiler or on the school machine that you can run on the source file to clean it up a bit for *nix, however, this might break it on some Windows text editors.

    This might not be the cause of your issue, but it might be the first thing to do. You might want to examine the source file in a hex editor and see what shows up.

    And btw, don't put "[URGENT]" in the topic. It makes me not want to reply to it since you're trying to put yourself in a higher priority than most of the other folks that need help, and it's a little arrogant in most circumstances.

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    22
    Sorry about the [URGENT]... Didn't think of that.. =\

    I've went thru my code to see if I find those \r chars and *nix and didnt find any

    I have managed to hold my scroll bar to see what the first lines after gcc driver.c were, here they are:
    Code:
    driver.c:1: error: stray '\377' in program
    driver.c:1: error: stray '\376' in program
    driver.c:1: error: stray '#' in program
    driver.c:1:4: warning: null character(s) ignored
    driver.c:1:6: warning: null character(s) ignored
    driver.c:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'n'
    And my first line of driver.c is a simple #include <stdio.h>
    =\

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Use a hex editor of some sort.

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    22
    How do I use a text editor? And which one to get? =\

  6. #6
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Hex editor, not text editor.

    If you're really stuck, you could try running this on your source code, although if you could run this, you probably could run your code as well.

    Code:
    #include <stdio.h>
    
    int main(int argc, char *argv[])
    {
    	int c;
    	FILE *fIn;
    	
    	if(argc < 2)
    	{
    		fprintf(stderr, "Usage: %s <file>\n", argv[0]);
    		return 1;
    	}
    	
    	fIn = fopen(argv[1], "rb");
    	if(fIn == NULL)
    	{
    		fprintf(stderr, "Error opening file \"%s\"\n", argv[1]);
    		return 2;
    	}
    	
    	while((c = fgetc(fIn)) != EOF)
    	{
    		printf("%#02x ", c);
    	}
    	fclose(fIn);
    	
    	return 0;
    }
    Then again, it all matters how you handle it and transfer it.

    Anyway... something like this:

    Code:
    ./a.out driver.c | more
    It should spit out every char in hexadecimal format.

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    22
    Woah.. I got lots of hexes!

    But now, what do I do? What do those hexes tell me?
    What did you want me to look for?

  8. #8
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Well, let's try skipping the problem, since you proved you can transfer a program and get it to run.

    Whatever you did to get this program to work, do it on your source code. Something like.... Copy and paste it to notepad and save it. Then take that copy that you saved and transfer that over to your Linux machine. If that works, you're fine.

    If that doesn't work (which I think it will work), then we have to study whatever this program I gave you spit out. Paste the first few lines of it, but again, only if you can't transfer the file.

  9. #9
    Registered User
    Join Date
    Jul 2008
    Posts
    22
    I've done that first option before...

    I grabbed the first few lines of hexes (without spaces) and pasted into this hex to ascii converter (http://www.dolcevie.com/js/converter.html)

    By plugging this in:
    Code:
    0xff0xfe0x23000x69000x6e000x63000x6c000x75000x64000x65000x20000x3c000x73000x74000x64000x69000x6f000x2e000x68000x3e000xd000xa000x2300
    I got this:
    Code:
    ?????#??i??n??c??l??u??d??e?? ??<??s??t??d??i??o??.??h??>???????#?
    So is this how my program is being read? =O

    WHAT DO I DOOOOOO! NOOOOOESSS

  10. #10
    Registered User
    Join Date
    Jul 2008
    Posts
    22
    Oooo snap! I got it...

    I actually did what you told me, paste it to notepad! ;D

    I didn't tried that before, but now it works ;D
    Just have some simple warnings, but those I can take care of.

    Thanks for lighting my day mister!

    Much <3

  11. #11
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Lessons that should be learned from this:

    1. Watch out for transferring of files from one platform to another.
    2. Don't say you've done something if you haven't.


    Have fun with your assignment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help Debugging my AVL tree program.
    By Nextstopearth in forum C Programming
    Replies: 2
    Last Post: 04-04-2009, 01:48 AM
  2. Compiling 3rd party code problem me too
    By siavoshkc in forum C Programming
    Replies: 1
    Last Post: 09-12-2007, 05:55 AM
  3. . . . . . . - . . . - -
    By The Brain in forum C++ Programming
    Replies: 17
    Last Post: 05-17-2005, 04:01 AM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM