Is it wrong to use ANOVA instead of a t-test for comparing two means? I have a distribution of salaries and I want to compare the difference in means for males and females. I know there's the student T-test for comparing two means but after suggesting ANOVA I received some criticism saying that ANOVA is for comparing more than two means.
What (if anything) is wrong in using it for comparing only 2 means?
 A: They are equivalent. An ANOVA with only two groups is equivalent to a t-test. The difference is when you have several groups then the type I error will increase for the t-tests as you are not able to test the hypothesis jointly. ANOVA does not suffer from this problem as you jointly test them through an F-test.
A: It is not wrong and will be equivalent to a t test that assumes equal variances. Moreover, with two groups, sqrt(f-statistic) equals the (aboslute value of the) t-statistic. I am somewhat confident that a t-test with unequal variances is not equivalent. Since you can get appropriate estimates when the variances are unequal (variances are generally always unequal to some decimal place), it probably makes sense to use the t-test as it is more flexible than an ANOVA (assuming you only have two groups). 
Update:
Here is code to show that the t-statistic^2 for the equal variance t-test, but not the unequal t-test, is the same as the f-statistic.
dat_mtcars <- mtcars

# unequal variance model
 t_unequal <- t.test(mpg ~ factor(vs), data = dat_mtcars)
 t_stat_unequal <-  t_unequal$statistic

# assume equal variance
 t_equal <- t.test(mpg ~ factor(vs), var.equal = TRUE, data = dat_mtcars)
 t_stat_equal <- t_equal$statistic

# anova
 a_equal <- aov(mpg ~ factor(vs), data = dat_mtcars)
 f_stat <- anova(a_equal)
 f_stat$`F value`[1]

# compare by dividing (1 = equivalence)
 (t_stat_unequal^2) / f_stat$`F value`[1] 
 (t_stat_equal^2) / f_stat$`F value`[1] # (t-stat with equal var^2) = F

