What's new

Closed How to create a simple dairy in C++

Status
Not open for further replies.

rev01

Addict
Joined
Feb 23, 2017
Posts
21
Reaction
2
Points
71
Age
28
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?
 
Tanung lang para saan ba return 0; dba gagamiyin lang sya pag may problem solving or value?
 
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.

Similar threads

Back
Top