🔒 Closed How to create a simple dairy in C++

Status
Not open for further replies.

rev01

Grasshopper
I primarily use cout<<""<<endl;
to start

Code:
#include <iostream> *// use this when you don't have arduino if you have use <liquidcrystal>
using namespace std; *// use this to avoid std::int or etc...

int main(){
cout << "dear diary" << endl;
cout<< "Continue doing it" << endl;
return 0
}
 
Ser, ayaw ma-compile

Code:
user@debian10:~/programming/cpp$ c++ diary.cpp && ./a.out
diary.cpp:1:21: warning: extra tokens at end of #include directive
#include <iostream> *// use this when you don't have arduino if you have use <liquidcrystal>
                     ^
diary.cpp:4:1: error: expected unqualified-id before ‘int’
int main(){

May problema yata sa mga comments.[/CODE]
 
ito dapat ginawa mo macocompileyan ^^... hahahahha copy paste pa di mo kabisado libc++ no...

#include <iostream>
using namespace std;

int main(){
cout << "dear diary" << endl;
cout<< "Continue doing it" << endl;
return 0
}
 
Oo boss, n00b pa kasi ko. Di ko pa alam kung ano yang libc at kung para saan. Pero aksidente ko na rewrite yung mga comments mo sa unang post tapos bigla na compile na. Eto yun:

Code:
user@debian10:~/programming/cpp$ cat rev01-diary.cpp 
#include <iostream>
/* use this when you don't have arduino if you have use <liquidcrystal>
 */
using namespace std; // use this to avoid std::int or etc...

int main(){
    cout << "dear diary" << endl;
    cout << "Continue doing it" << endl;
    return 0;
}
user@debian10:~/programming/cpp$ 

user@debian10:~/programming/cpp$ c++ rev01-diary.cpp && ./a.out
dear diary
Continue doing it
user@debian10:~/programming/cpp$

Yung updated code mo, copy-paste ko ayaw din ma-compile. May kulang yata semicolon sa result statement? Ano sa palagay mo?
 
Kapag idineclare mo yung function na may return value, eg

Code:
int myint_function(){
  return <some int value>;
}

char mychar_function() {
  return <some_char>;
}

Because 'main' function is kinda a special function such that it is the entry point of your program, return 0 indicates success.
 
Status
Not open for further replies.

About this Thread

  • 5
    Replies
  • 1K
    Views
  • 3
    Participants
Last reply from:
homer_simpson

Trending Topics

Online now

Members online
1,164
Guests online
4,199
Total visitors
5,363

Forum statistics

Threads
2,338,420
Posts
29,303,907
Members
1,124,292
Latest member
eezakimak
Back
Top