Jump to content

the reason for errors in this simple read function

- - - - -

  • Please log in to reply
3 replies to this topic

#1
jackson6612

jackson6612

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
I THINK I HAVE RESOLVED THE PROBLEM! THANKS.

Hi :)

I was trying to write a read function. But I'm getting the following errors. Could you please tell me the reason for these errors? Thanks a lot.


error: stray '\224' in program|

error: stray '\224' in program|

error: stray '\224' in program|

error: stray '\224' in program|

error: stray '\224' in program|

error: stray '\224' in program|

In function 'STUDENT readdata()':|

error: 'enter' was not declared in this scope|

error: expected ';' before 'the'|

error: expected ';' before 'sex'|

error: expected ';' before 'the'|

||=== Build finished: 10 errors, 0 warnings ===|



// user defined read function using structure


#include <iostream>

#include <cstdlib>


using namespace std;


/////////////////////////////////////////////

struct STUDENT { int rollno; char sexcode; float marks;};

/////////////////////////////////////////////


//------------------------------------------

 STUDENT readdata( )

    {

        STUDENT s;


        cout << ”enter the roll no.: ”;

        cin >> s.rollno;


        cout << ”enter sex code: ”;

        cin >> s.sexcode;


        cout << ”enter the marks: ”;

        cin >> s.marks;


        return (s);

    }

//--------------------------------------------



int main( )


    {

        int i; STUDENT s1;


        s1 = readdata( );


        cout << "roll no.: " << s1.rollno << endl;


        cout << "sex code: " << s1.sexcode << endl;


        cout << "marks: " << s1.marks << endl;


        system("pause");


        return 0;


    }


I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)

#2
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1
Minor observation: I suggest you read some about coding styles. There's nothing wrong with your current one, except that it might not be as clear as it could be. Here are some links you can start with: programming style, coding conventions, indent style and C++ coding standard.
A conclusion is where you got tired of thinking.
#define class struct    // All is public.

#3
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
Ah, were you copying the code off an online assignment or from Microsoft Word? Your quotes have been replaced with Microsoft smart quotes (i.e. ” and not ")
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#4
jackson6612

jackson6612

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts

Flying Dutchman said:

Minor observation: I suggest you read some about coding styles. There's nothing wrong with your current one, except that it might not be as clear as it could be. Here are some links you can start with: programming style, coding conventions, indent style and C++ coding standard.

Thank you, Dutchman. I have been trying to write the code as clear as possible. Hope the mission will be accomplished soon.

Alexander said:

Ah, were you copying the code off an online assignment or from Microsoft Word? Your quotes have been replaced with Microsoft smart quotes (i.e. ” and not ")

Hi Alexander

It was copied from MS Word. I had copied the 'draft' version on my flash.

Best wishes
Jackson
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users