简体   繁体   中英

C Programming Pointers — Why are my values changing?

Whenever I do ./thread 88 90 92 I get this

4

46

56

57

54

57

46

and I'm not sure why. It should print out the argc which should be 3 (it says 4) then print out the 3 numbers that i gave it which is 88 90 92. Then it should print out 90 92 88. Did i mess my pointers up? This is my first C program that I have done by myself. Advice is appreciated! Thanks!

#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>

int avg;
int max = 0;
int min;
int j;


int main(int argc, char* argv[]){
    printf("%d\n", argc);
    j = argc;


    printf("%d\n", avg);
    printf("%d\n", max);
    printf("%d\n", min);



}

The first element is the program name. argc is 4, and the values you want are [1] through [3] (skip 0).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM