Hey guys. I'm having some issues with my Visual Studio 2008 Pro. I'm trying to compile the following code, included in the link but, whenever I try compiling the code, I get like 5 erros: The errors are listed below.

Why is it that moving certain declarations around changes and/or removes erros?

The errors are as outlined below:

1>------ Build started: Project: brute, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.cpp(15) : error C3861: 'strcpy': identifier not found
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.cpp(24) : error C3861: 'strcmp': identifier not found
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.cpp(34) : error C3861: 'strcmp': identifier not found
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.cpp(44) : error C3861: 'strcmp': identifier not found
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.cpp(54) : error C3861: 'strcmp': identifier not found
1>Build log was saved at "file://c:\Users\ProgrammerX\Documents\Visual Studio 2008\Projects\brute\brute\Debug\BuildLog.htm"
1>brute - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Dani AI

Generated

Short version: the compiler is treating your file as C, and Visual C++ in VS2008 expects older C (no C99 mixed declarations), so C++-style loop declarations and a missing/ misplaced semicolon will trigger a cascade of syntax errors. The replies already on the thread point you in the right directions — the real fix is to make the compiler and the code agree, then fix the first real syntax error and recompile.

Checklist of practical fixes (in order)

  • Confirm how the file is being compiled: .c files -> C compiler, .cpp -> C++ compiler. If you intended C++, rename the file to .cpp or force C++ compilation (Project → Properties → C/C++ → Advanced → Compile As → “Compile as C++ (/TP)”).

  • If you must compile as C (VS2008 C compiler), write C89-style code: put all declarations at the start of a block (declare loop counters before the loop). Example:

    int main(void) {
        int i;
        for (i = 97; i <= 122; ++i) {
            /* ... */
        }
    }
  • Fix the first real error reported in the build log — later errors are usually just fallout. Look at the line before the reported error line for a missing semicolon or stray brace, as suggested.

Dealing with string functions and the VC warnings

  • If you are using C functions like strcpy, include the proper header (string.h for C, <cstring> for C++) and either switch to the safer secure functions (strcpy_s) or silence the deprecation: add _CRT_SECURE_NO_WARNINGS to your Preprocessor Definitions (Project → Properties → C/C++ → Preprocessor) or add #define _CRT_SECURE_NO_WARNINGS before your includes. highlighted the deprecation message; prefer safer APIs where appropriate.

If you want modern C99 features instead of rewriting code, consider compiling with a C99-capable compiler (GCC/MinGW, clang) or moving to a newer toolchain — VS2008 does not implement full C99. Follow these steps and fix the earliest syntax error first; most of the 40 errors you saw will disappear once the first one is resolved.

Recommended Answers

All 9 Replies

Is this a C or Cpp progect? If its a C project try including the string.h header.

Thanks, I added string.h; it cleared up my strcpy() problem, but now I'm getting about 40 errors, which include stuff like:
1>------ Build started: Project: brute, Configuration: Debug Win32 ------
1>Compiling...
1>main.c
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(16) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 9.0\vc\include\string.h(74) : see declaration of 'strcpy'
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(21) : error C2143: syntax error : missing ';' before 'type'
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(21) : error C2143: syntax error : missing ';' before 'type'
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(21) : error C2143: syntax error : missing ')' before 'type'
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(21) : error C2143: syntax error : missing ';' before 'type'
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(21) : error C2065: 'i' : undeclared identifier
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(21) : error C2065: 'i' : undeclared identifier
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(21) : error C2065: 'i' : undeclared identifier
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(21) : error C2059: syntax error : ')'
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(22) : error C2143: syntax error : missing ';' before '{'
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(23) : error C2065: 'i' : undeclared identifier
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(31) : error C2143: syntax error : missing ';' before 'type'
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(31) : error C2143: syntax error : missing ';' before 'type'
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(31) : error C2143: syntax error : missing ')' before 'type'
1>c:\users\programmerx\documents\visual studio 2008\projects\brute\brute\main.c(31) : error C2143: syntax error : missing ';' before 'type'

First warning: disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. You don't care that VC doesn't like strcpy so turn the error off.

Next error: look on line 21 and before for the missing ';'

First warning: disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. You don't care that VC doesn't like strcpy so turn the error off.

Next error: look on line 21 and before for the missing ';'

I've tried and I really don't see any lines missing a ';'....

Well what can we say? Our crystal balls must be on the fritz. You might have to help us see your problem...

Looks like your paste has expired.

Why don't you copy and paste the code here itself?

Next error: look on line 21 and before for the missing ';'

Or with errors of that nature (missing X before Y) look on the first line of code before the line given, 21 in this case particularly if Y is the first thing on the error line.

> Looks like your paste has expired.
No it hasn't, the OP just can't paste URLs properly. Delete the trailing ;

> for(int i = 97; i >= 97 && i <= 122; i++)
Assuming you're compiling this as C, then the int declaration inside the for loop is NOT supported.
This is a C++ feature, or a C99 feature.
Since you're using m$, you're never going to get a C99 compiler.

Declare i at the start of the block, old-school style.

commented: Good catch!! +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.