So anyway, here are my two tools:
Making small tools in C
#1
Posted 29 September 2012 - 02:53 PM
So anyway, here are my two tools:
*insert cliché inspirational quote here*
#2
Posted 30 September 2012 - 07:12 AM
Anyway, I've made a small application, like a console application, And I plan to make a full on console call "The Terminal"
Here is the code:
main.cpp
#include <iostream> #include <sys/stat.h> #include <string> #include "functions.h" using namespace std; int terminal() { string command = ""; const char *command_cpy; cout << endl << "$ "; getline(cin, command); if(command == "exit") { exit(0); } if(command == "delete") { string file; const char *file_cpy; cout << " Delete file: "; getline(cin, file); file_cpy = file.c_str(); if(file == "cancel") { cout << " Delete file: canceled!" << endl; terminal(); } else if(file == "") { cout << " Path cannot be empty!" << endl; terminal(); } else if(!file_exists(file_cpy)) { cout << " Delete file: " << file_cpy << " does not exist!" << endl; terminal(); } else if(is_file(file_cpy) == 0) { cout << " Delete file: " << file_cpy << " is not a file!" << endl; terminal(); } else { if(remove(file_cpy) == 0) { cout << " Delete file: " << file_cpy << " deleted successfully!" << endl; terminal(); } else { cout << " Delete file: " << file_cpy << " could not be deleted!" << endl; terminal(); } } } if(command == "") { cout << endl; terminal(); } else { cout << " Command: " << command << " does not exist!" << endl; terminal(); } return 0; } int main() { cout << "Welcome to The Terminal. Read the manual for more info." << endl; terminal(); return 0; }
funtions.h
#include <iostream> #include <sys/stat.h> #include <string> using namespace std; int file_exists(const char *file_name) { struct stat buf; int i = stat(file_name, &buf); if(i == 0) { return 1; } else { return 0; } } int is_file(const char *path) { struct stat s; if(stat(path, &s) == 0) { if(s.st_mode & S_IFREG) { return 1; } else { return 0; } } else { return 0; } }
*insert cliché inspirational quote here*
#3
Posted 05 October 2012 - 02:12 AM
Rumors of my demise have been greatly exaggerated.
#4
Posted 05 October 2012 - 08:21 AM
May I ask why you're writing a terminal that can only run within a terminal?
I was gonna ask this, but I didn't wanna sound stupid >.>
lest there be some strikingly obvious reason
#5 Guest_ElatedOwl_*
Posted 05 October 2012 - 12:57 PM
We don't always need an excuse to program.May I ask why you're writing a terminal that can only run within a terminal?
#6
Posted 07 October 2012 - 02:03 AM
This is true.We don't always need an excuse to program.
Why just earlier today I was testing out an unfamiliar IDE, so I wrote a window with a (_|_( button that says "BUTTS" if you click it.
Ahh, technology.
Rumors of my demise have been greatly exaggerated.
#7
Posted 07 October 2012 - 08:40 AM
This is true.
Why just earlier today I was testing out an unfamiliar IDE, so I wrote a window with a (_|_( button that says "BUTTS" if you click it.
Ahh, technology.
priceless
#8
Posted 13 October 2012 - 12:46 PM
This is true.
Why just earlier today I was testing out an unfamiliar IDE, so I wrote a window with a (_|_( button that says "BUTTS" if you click it.
Ahh, technology.
Is it opensource?
(//MihiPotestasSit\\)
#9
Posted 15 October 2012 - 04:20 PM
LGPL. I was using it to test out Qt creator and Qt has a strict LGPL license. You want the source? It's nothing special.Is it opensource?
Rumors of my demise have been greatly exaggerated.
#10
Posted 16 October 2012 - 01:41 AM
LGPL. I was using it to test out Qt creator and Qt has a strict LGPL license. You want the source? It's nothing special.
Just post it then
Never actually saw any Qt source which wasn't overly complicated.
(//MihiPotestasSit\\)
#11
Posted 16 October 2012 - 05:51 AM
#ifndef COMMUNICATE_H #define COMMUNICATE_H #include <QWidget> #include <QApplication> #include <QPushButton> #include <QLabel> class Communicate : public QWidget { Q_OBJECT public: Communicate(QWidget *parent = 0); private slots: void OnStupid(); private: QLabel *label; }; #endif // COMMUNICATE_H
communicate.cpp
#include "communicate.h" Communicate::Communicate(QWidget *parent) : QWidget(parent) { QPushButton *butts = new QPushButton("(_|_(", this); butts->setGeometry(50,80,75,30); label = new QLabel("", this); label->setGeometry(190,80,80,30); connect(butts, SIGNAL(clicked()), this, SLOT(OnStupid())); } void Communicate::OnStupid() { QString butts = "BUTTS"; label->setText(butts); }
main.cpp
#include "communicate.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); Communicate window; window.setWindowTitle("Butts"); window.show(); return app.exec(); }
Rumors of my demise have been greatly exaggerated.
#12
Posted 16 October 2012 - 07:07 AM
thank you for using Qt Qsoftware
#13
Posted 16 October 2012 - 10:52 AM
(//MihiPotestasSit\\)
#14
Posted 16 October 2012 - 10:51 PM
Rumors of my demise have been greatly exaggerated.
#15
Posted 20 October 2012 - 04:24 PM
I don't get what "label->" does though.
And some other stuff that I guess is Qt knowledge, which I lack.
(//MihiPotestasSit\\)
#16
Posted 20 October 2012 - 10:15 PM
-> is an operator that always precedes an object, and can refer to a function or variable inside that object.
Say I made a class like this:
class tree { public: string fruit; }
Then made an object of that class like
tree : appleTree { fruit = "apples"; }
I'd access the value of fruit in apple tree like this:
appleTree->fruit;
Rumors of my demise have been greatly exaggerated.
#17
Posted 21 October 2012 - 01:19 AM
*insert cliché inspirational quote here*