sorry for my bad english.
I need some help to find an error in my c program, hope someone can tell me what's wrong with my program. I try to make a program to shutdown my linux, but when I using sprintf to combine the command, it's going wrong.
Code:
#include <stdlib.h>#include <stdio.h>
#include <string.h>
#include <unistd.h>






void processval(int sel, char *pass){
	char *comm;
	switch(sel){
		case 1:
			sprintf(comm,"echo %s | sudo -S -b poweroff",pass);
			system(*comm);
		break;
		case 2:
			sprintf(comm,"echo %s | sudo -S -b reboot",pass);
			system(*comm);
		break;
		case 3:
			sprintf(comm,"echo %s | sudo -S -b killall icewm",pass);
			system(*comm);
		break;
		case 4:
			system("xscreensaver-command -lock");
		break;
	}
}


int main(){
	int i,sel;
	i = 0;
	char yrn,c;
	system("echo Hello");
	char *pass = getpass("Password:");
	start:
	sel = 0;
	printf("Process to:\n");
	printf("1.Shutdown\n");
	printf("2.Reboot\n");
	printf("3.logout\n");
	printf("4.lockscreen\n");
	printf("5.exit\n\n");
	printf("Choose by number:");
	scanf("%d",&sel);
	printf("\n Are you sure?[y/n]");
	choose:
	scanf("%c",&yrn);
	switch(yrn){
		case 'y':
			processval(sel,pass);
		break;
		case 'n':
			goto start;
		break;
		default:goto choose;
	}
	ends:
	return 0;
}
Please help me, to fix the problems. Thanks.