Jump to content

How could this be modifed to two seperate inputs?

mikeeginger


My question is how if it can could this programm be modified to

accept two seperate inputs? if not any tips on creating one that can and validate both inputs to the same degree

IntelCorei54670k,Maximus VI Formula,Swift tech H220, 16gigs Corsair Dominator platinums, Asus DCUII GTX 780,1x256 840 evo, 1x 2TB Segate barracuda, Corsair AX 860, 

3 X Noctua NF-F12, 2x Noctua NF A-14, Ducky Shine 3 Blue Leds Blue switches, Razer Death Adder 2012, Corsair vengence 1400  

Link to comment
Share on other sites

Link to post
Share on other sites

could you be less vauge?

Please Quote so i know you have replied. | If we have provided a solution to your problem mark it with answer found.

And also please read the COC and avoid the embarrassment and lecture that will ensue.

Link to comment
Share on other sites

Link to post
Share on other sites

could you be less vauge?

Ok i need to make a program that can accept two separate inputs and validate

then assign a grade to one of the inputs based on a percentage

In C language using Visual studio or some other c compiler/editor

 

 

sorry for being vague

IntelCorei54670k,Maximus VI Formula,Swift tech H220, 16gigs Corsair Dominator platinums, Asus DCUII GTX 780,1x256 840 evo, 1x 2TB Segate barracuda, Corsair AX 860, 

3 X Noctua NF-F12, 2x Noctua NF A-14, Ducky Shine 3 Blue Leds Blue switches, Razer Death Adder 2012, Corsair vengence 1400  

Link to comment
Share on other sites

Link to post
Share on other sites

its alright but to be honest im starting to program in C and C# but if you want an answer that will help you should head over to http://stackoverflow.com/ im sure they can help you way faster and they know what there talking about.

Please Quote so i know you have replied. | If we have provided a solution to your problem mark it with answer found.

And also please read the COC and avoid the embarrassment and lecture that will ensue.

Link to comment
Share on other sites

Link to post
Share on other sites

Ok i need to make a program that can accept two separate inputs and validate

then assign a grade to one of the inputs based on a percentage

In C language using Visual studio or some other c compiler/editor

 

 

sorry for being vague

Well I am assuming by inputs you mean at run-time the user types in information.  (As opposed to command line arguments, if you meant command line arguments I can help you with that as well...it is actually easier, but less flexibility imo)

 

Anyways onto the point.  Here is an example I wrote a long time ago for reading two inputs:

int main() {	char a[1024];	int val;	char line[1024];	int i;	int z;	a[0] = 0;	while(1) {		printf("Enter characters in word:   ");		if(fgets(line, 1024, stdin) == 0) { /* Reads the user input (triggered by enter) */			clearerr(stdin);			return(-1);		}		if(sscanf(line, "%s", a) == 1) /* Read in from string, and %s means it will put the first word as a  */			break;	}	while(1) {		printf("Enter character not in word:   ");		if(fgets(line, 1024, stdin) == 0) {			clearerr(stdin);			return(-1);		}		if(sscanf(line, "%d", &val) == 1)  /* %d means digit, it will read in a digit to the val  */			break;	}	return 0;}

Sorry for the weird comments, I was learning ANSI C when I wrote that :P

 

Anyways the keys are fgets and sscanf.

fgets will take in character array and stdin (the user input) and wait until the user hits enter.  When the user hits enter everything the user had written in a line will be copied to the character array.

sscanf takes an character array and puts the values into whatever primitive you want, %s is string, %d is integer, %f is floating point.

 

If you need any help with reading or figuring stuff out let me know

 

its alright but to be honest im starting to program in C and C# but if you want an answer that will help you should head over to http://stackoverflow.com/ im sure they can help you way faster and they know what there talking about.

I would say post in both, there are a fair amount of people who are good here and on stackoverflow, just the overflow community is more active....also there are cases where overflow can take things too far (from my experience) :P

0b10111010 10101101 11110000 00001101

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×