Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not zero terminating string to display #1

Open
deepcoder opened this issue May 24, 2021 · 0 comments
Open

Not zero terminating string to display #1

deepcoder opened this issue May 24, 2021 · 0 comments

Comments

@deepcoder
Copy link

Hello, thanks for this code! Helping me learn how I2C works on Intel Linux box.

I believe your code does not correctly terminate the character string from the command line in some cases.
Simple fix that seems to handle all cases and still yields correct display:

	//Setup the text  argument that was passed to main. remove null and add some extra spaces.

        for(i = 0; i < (strlen(argv[3])) ; i++){
	        text[i] = argv[3][i];
        }
        for(i = 0; i < 4 ; i++){
                text[strlen(argv[3])+i] = 32;
        }
        // terminate string
        text[strlen(argv[3])+4] = 0;

Realize this is very old code, but still helpful. Again, thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant