Jump to content

FaiL___

Member
  • Posts

    164
  • Joined

  • Last visited

Everything posted by FaiL___

  1. Hi, I have ordered a 1060 6GB Zotac and it is arriving in the next 24 hours, but suddenly realised that I didn't check to see if it fits my MoBo. I currently have a 750Ti, and was wondering if that meant it was ok? new to this whole thing.
  2. Full code is: #include <stdio.h> #pragma warning(disable: 4996) int main(int argc, char *argv[]) { float numberOne = 0, numberTwo = 0, answer = 0; char operatorSymbol[1]; int numberOfValuesRead = 0; if (argc == 4) { sscanf(argv[2], "%s", &operatorSymbol); numberOfValuesRead = sscanf(argv[1], "%f", &numberOne); if (numberOfValuesRead == 1) { numberOfValuesRead = sscanf(argv[3], "%f", &numberTwo); if (numberOfValuesRead == 1) { if (strcmp((operatorSymbol, "*") == 0)) { answer = numberOne * numberTwo; printf("%f", answer); } else if (strcmp((operatorSymbol, "/") == 0)) { if (numberTwo == 0) { printf("invalid output"); } else { answer = numberOne / numberTwo; printf("%f", answer); } } else if (strcmp((operatorSymbol, "+") == 0)) { answer = numberOne + numberTwo; printf("%f", answer); } else if (strcmp((operatorSymbol, "-") == 0)) { answer = numberOne - numberTwo; printf("%f", answer); } } else { printf("invalid input"); } } else { printf("invalid input"); } } getchar(); }
  3. Hi, I'm meant to be basically making a calculator, but for some reason, it keeps saying this error message. The code is breaking on this line: if (strcmp((operatorSymbol, "*") == 0)) Thanks in advance for helping, if you could a) fix it, b) explain to me why it is doing this so I can learn, that'd be great. TY
  4. This is my new(ish) code: #include <stdio.h> #include <stdlib.h> //hi babe #pragma warning(disable: 4996) int main(int argc, char *argv[]) { float numberOne = 0, numberTwo = 0, answer = 0; if (argc == 3) { numberOne = atof(argv[1]); numberTwo = atof(argv[2]); if ((numberOne == 0) && (argv[1] != 0)) { printf("invalid input"); } else if ((numberTwo == 0) && (argv[2] != 0)) { printf("invalid input"); } else if ((numberOne == 0) && (argv[1] == 0)) { answer = numberOne + numberTwo; printf("%f", answer); } else if ((numberTwo == 0) && (argv[2] == 0)) { answer = numberOne + numberTwo; printf("%f", answer); } else if ((numberOne != 0) && (numberTwo != 0)) { answer = numberOne + numberTwo; printf("%f", answer); } } }
  5. But if it is a letter, it will be converted into 0 again, I need to be seeing if a letter was entered or not, if a letter was entered, the float value of the argument (atof(argv[2]) is 0, so I check to see if argv[2] is 0, if it is, fine, if not, not fine, it works for argv[1], but not argv[2]. I am leaving it for the night now as it is 1.30am where I am, but in the morning, I will add my modified code, which is more organised and I think might actually be very close to working. Cheers anyway though.
  6. I have changed this now after realising it myself, but am now having trouble because when I do: else if ((numberTwo == 0) && (argv[2] == 0)) if argv[2] is actually 0, it just says no it is not and skips to the next else if statement. Help?
  7. Hi, I posted something similar to this last week (still stuck), but I now have a different problem. I can retrieve two values from the command line (which is what I was having trouble with originally) and can print them to the screen just by doing: printf(argv[1]; //OR printf(argv[2]); however, when I try to assign these to variables, the variables just contain 0.000000000. I don't know why this does this, but I need to be able to assign them to variables so that I can add them together. This is the code I have so far: #include <stdio.h> #pragma warning(disable: 4996) int main(int argc, char *argv[]) { double numberOne, numberTwo = 0, answer = 0; if(argc = 3) { /* First number entered in the command line */ printf("The first argument is: %s", argv[1]); numberOne = atof(argv[1]); printf("\n"); printf("%f", &numberOne); /* Second number entered in the command line */ printf("The second argument is: %s", argv[2], "\n"); numberTwo = atof(argv[2]); printf("\n"); printf("%f", &numberTwo); printf("\n"); /* Calculations and output */ answer = numberOne + numberTwo; printf("The answer of %f + %f is: %f.", &numberOne, &numberTwo, &answer); } else { printf("Something went wrong"); } getchar(); } Thanks in advance.
  8. I have lied, for some reason, it is now just outputting the last number inputted
  9. Thank you, I just had to change a few things to accommodate a space between the two numbers (e.g. 4 7)
  10. I have a build error saying that atoi is undefined...
  11. That won't work unfortunately as the code is marked automatically and will need to be able to take it directly from the command line. The sample code we were given is for one entry: /* file CommandLineInput.c *Author Jim Smith * 23 september 2017 * simple example of reading and checking a number from the command line */ #include <stdio.h> #pragma warning(disable: 4996) // this is 'magic'... to keep the code as standard C int main (int argc, char *argv[]) { float theNumber=0; int numberOfErrors=0; int numberOfValuesRead = 0; //start by checking that a single number was input - so the value of argc is 2 if ( argc !=2) { numberOfErrors ++; printf("this programme should be called with one parameter - the number to be displayed\n"); } if (argc ==2) //programme was called correctly { /*sscanf() takes three type of parameters: the first tells it where to read from -in this case argv[1] is the name of the string where the second thing on the comand line was stored the second tells it what to try and read from that place - in this case one floating point number - but you can add more - of course not all conversios may be possible the third tells it where to put its results - in this case we want it stored as a variable called "theNumber", -note that we use &thenumber to mean "the place where this variable is stored" - don;t worry about this for now - we'll come back ot it in activity 10 It returns an integer saying how many successful read/conversions it has done */ numberOfValuesRead = sscanf(argv[1],"%f",&theNumber); if (numberOfValuesRead ==1) { printf(" The number entered was %f \n",theNumber); } else{ printf("Something must have gone wrong because %d values were successfully read \n", numberOfValuesRead); printf("perhaps the second thing on the command line could not be interpreted as a number?\n"); } } printf("press any key then <return> to exit\n"); //this line is just there to leave the messages on screen for youy to read scanf("%f",&theNumber); return (0); }
  12. Normally it would be, but I'm doing it as a command line, so essentially if you run it from a cmd you can do (pseudocode): "run MyProgram 3 4" and that would (in my case) add three and four and output 7
  13. So I have just started CompSci at Uni and I am trying to pass multiple arguments (2 to be exact) to a command line so that it adds the two together and outputs the sum. I can do one, but how do I do the other? This is what I have so far: #include <stdio.h> #pragma warning(diable: 4996) int main(int argc, char *argv[]) { float answer = 0, numberOne = 0, numberTwo = 0; int numberOfErrors = 0; int numberOfValuesRead = 0; if (argc != 2) { numberOfErrors++; printf("invalid input"); } else if (argc == 2) { numberOfValuesRead = sscanf(argv[1], "%f", &answer); if (numberOfValuesRead == 2) { answer = argv[1] + argv[2]; printf("%f", answer); } } } Thanks in advance.
  14. I cannot share a screenshot, but it is definitely chrome/facebook. Popups are already blocked.
  15. I've never seen it either, but a quick Google search shows it's actually quite a common issue.
  16. My Granddad is trying to log into Facebook on his Windows 10 PC using Chrome. It comes up with a message saying "Let's check for malware". It runs it's own scanner but doesn't seem to do a callback to Facebook to register the scan. I have checked the url and it seems legit. I tried the most powerful VPN I know with no avail. After some research, I found that this is a problem with chrome. I tried it in Edge, but the issue still arises. Thanks for the help in advance.
  17. FaiL___

    Rust Server

    I have a PC with 8GB, but I need that to actually play Rust ? on the other hand, how much do the online rental services cost?
  18. FaiL___

    Rust Server

    My upload speed is pretty good to be honest, I get about 20mb/s consistently
  19. FaiL___

    Rust Server

    Hi, I am looking to host a Rust Server but I don't want to pay a subscription for any online services. I know you can host it with a dedicated server, but I was wondering if anyone else has done this, and if so, what specs was the server? I have a laptop with an i3 and 4GB ram just lying around, so would ideally be using that. Thanks in advance.
  20. Already tried, it was already allowed
  21. No, well, unless Windows 10 has a built in one that would affect it, no, I don't.
×