0

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?

Edited by Nick Evan: Added [CODE] tags

Attachments
#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;

}
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by SOME one2020
0

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;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.