0

This is my code:

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main () {
    int n, x, distress=0, z;
    char y;
    cin >> n >> x;
    for (int i=0; i<n; i++) {
        cin >> y >> z;
        if (y=='+') {
            x+=z;
        }
        if (y=='-') {
            if (x>=z) {
                x=x-z;
            }else{
                distress++;
            }
        }

    }
    cout << x << " " << distress;
    return 0;
}

It runs well on an online compiler but when I run it using Sublime Text 3 CPPFastOlympicCoding package it gives me this error:

ld: file not found: Ice
collect2: error: ld returned 1 exit status

I am not sure how to fix this, btw I am using an M1 mac if that matters.

  • My first suspicion is that there is a space in your file's path someplace, and the plugin's build system isn't handling it correctly. What is the full path and name of the file you're trying to compile? – MattDMo May 17 '22 at 14:36
  • Also, somewhat unrelated, but I'd strongly suggest reading https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice and https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h. – MattDMo May 17 '22 at 14:38
  • Thanks MattDMo, that worked. I had a gap in my file name, I was trying to compile code for answer to a problem in Code Forces. – Anonymousstriker38596 May 18 '22 at 13:18
  • I'll keep your suggestion in mind too. – Anonymousstriker38596 May 18 '22 at 13:19

0 Answers0