0

I'm new in C and mplab x and I have a hw need to do in this IDE. my printf works not as it should be so I want to knwo why and how can I change it.

setting:

mplab x IDE version:5.45

mplab xc32 compiler:4.00

pickit3

Uno32:PIC32MX320F128H

Windows 10

using Coolterm to input data

below is my testing code(not hw)

#include <stdio.h>
int main(void)
{
    char c[80];
    int i;    
    printf("name here:");
    scanf("%79s", c);
    printf("\nage here:");
    scanf("%d", &i);
    printf("\nname %s, age%d",c, i);
    return 0;
}

This is the result:

this is result

also what I did in coolterm was press "abcde" and "Enter" only.

Barmar
  • 741,623
  • 53
  • 500
  • 612
jackey
  • 11
  • 1
  • It would be sensible to show the real code — at least to put `int main(void) {` after `#include ` and `return 0; }` at the end. The `while (1);` loop is presumably to avoid the process terminating. There are probably better ways to achieve much the same result — maybe there is a `pause()` function declared in ``? – Jonathan Leffler Jan 13 '22 at 23:32
  • 2
    The code you have posted (at least, the version I'm looking at now, I guess you've iterated it) looks fine. It works for me. I don't see anything wrong with it (other than that the `\n`'s aren't where I'd put them). I don't think it could possibly have generated the output in that image link you posted. I suspect you've been making many changes, trying many things, and that the output in that image link you posted was from some other version of your program, that did have real problems. But, again, the version that's there now looks fine. – Steve Summit Jan 14 '22 at 00:07
  • @Steve Summit , I reinstalled everyting but it still looks like this. whatever thank you! – jackey Jan 14 '22 at 00:16
  • 2
    It works fine for me: https://onlinegdb.com/WMB9LXsi0 – Jerry Jeremiah Jan 14 '22 at 02:24
  • @ Jerry Jeremiah At least this website helps me how it should work. thanks!!!!!(although you didn't "solve" my problem ). – jackey Jan 15 '22 at 02:47

0 Answers0