i have write that code i m new in programming this code doesnt work in one source file but when i type exact same in other file it start working

#include <iostream.h>
main()
{
                char std1[20], std2[20]
            cout << "enter  your name student"<<"\n";
           cin >> std1;
               cout << "enter  your name student2" <<"\n";
               cin>> std2;
            cout << std1 << "\n" << std2;
       

return 0;

}

any idea any one?

There are three issues:

>#include <iostream.h>
Depending on the age of your compiler, this may or may not work. <iostream.h> has been replaced with <iostream> and all contents placed in the std namespace.

>main()
C++ does not support implicit int. You must specify the return type of int.

>char std1[20], std2[20]
This is probably the cause of your error. You forgot to terminate this statement with a semicolon.

Fixed and updated:

#include <iostream>

int main()
{
    using namespace std;

    char std1[20], std2[20];

    cout << "enter  your name student"<<"\n";
    cin >> std1;
    cout << "enter  your name student2" <<"\n";
    cin>> std2;
    cout << std1 << "\n" << std2;

    return 0;
}

thankkkkkkkkkkkkkkkkkkkkkkks it worked it was semicolon

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.