jaepi 22 Practically a Master Poster

In addition, can any of you here suggest a good application that i can practice threading in linux? Thank you again.

jaepi 22 Practically a Master Poster

Been googling around but I'm not satisfied with the hits. Consulting experts here is the best option I can think of. Daniweb had helped me a lot. =)

jaepi 22 Practically a Master Poster

Thank you for that explanation.

jaepi 22 Practically a Master Poster

Hello there, I've been studying c++ for about a month. Currently, I'm indulging my self to pointers to be used in classes and functions because i have to familiarize myself with threading. Any of you here knows some good tutorials in threading, preferably html based tutorials. Or, suggestions on what to study first before digging deep into threading. Thank you.

jaepi 22 Practically a Master Poster

thank you very much...rep points to the both of you...uhmmm, i have a question...

pS->first_name

is synonymous to...

(*ps).first_name

right??uhmmm..what about this one?

*(ps).first_name

thank you again sirs...

jaepi 22 Practically a Master Poster

should i include the * before pS? after i changed 's' to 'pS' i still got an error:

ptr-struct.cpp:24: error: request for member `first_name' in `pS', which is of non-class type `MyClass*'
ptr-struct.cpp:24: error: request for member `last_name' in `pS', which is of non-class type `MyClass*'
ptr-struct.cpp:24: error: request for member `id_no' in `pS', which is of non-class type `MyClass*'
ptr-struct.cpp:24: error: request for member `age' in `pS', which is of non-class type `MyClass*'
jaepi 22 Practically a Master Poster

haha...you earn a reputation point!

jaepi 22 Practically a Master Poster

you can study some codes and techniques used here -> http://cssplay.co.uk

i was once a noob...css codes here helped me to polish my skills...lol...OA

jaepi 22 Practically a Master Poster

i have here a code that uses pointers to manipulate data in a class...i have a problem of how to show them on screen...i think im using an erroneous syntax...lol...

#include <iostream>
#include <string>
using namespace std;

class MyClass{
        public:
                string first_name, last_name, id_no;
                int age;
};

int main(){

        MyClass s;
        MyClass* pS;

        pS = new MyClass;

        pS->first_name = "John Paul ";
        pS->last_name = "Dingle ";
        pS->id_no = "0321183 ";
        pS->age = 20;



        cout << s.first_name; << s.last_name << s.id_no << s.age << endl;

        delete pS;
        return 0;
}

you think im doing the right thing?? lol... help

jaepi 22 Practically a Master Poster

i was testing something...lol..thanks dude...reputation point for you! :)

jaepi 22 Practically a Master Poster

hello, there...

how would you send a signal to end this loop

string s;
int counter;
while(cin >> s){
   counter++;
}

thanks...

jaepi 22 Practically a Master Poster

thank you for being so kind :)

jaepi 22 Practically a Master Poster

Is this for a homework assignment? If it is, show some effort before asking for us to do it for you.

it's not an assignment...it's part of my self study...dude, im not asking anyone here to do it for me, im just asking for reference because i have no idea how a console based web server looks, does and function...it's a self study, how can i learn if you'll do it for me anyway...

jaepi 22 Practically a Master Poster

hello there, uhhmmm...anyone here could give me an idea or point me a reference on how web server application are created (console based) using c++...i'd be using threading, processes, synchronization and http protocol...

a reference to any website or books would be nice...thank you...

jaepi 22 Practically a Master Poster

hello there...is there a way to check if the file you get is the file you really want...like for example, you want an .iso file, if yo placed any file like .txt, the system will exit...but if you placed a file with .iso extension, it will continue to run...thanks...

jaepi 22 Practically a Master Poster

hello there, im currently doing some programming in burning an iso file using c++ and LINUX...is it possible to check if a medium(cd-rw) is empty or has a data inside...because im going to make a function that checks if a medium is blank or not, like:

if(cd-rw is empty){
   burn files
}else{
   empty cd-rw
   burn files
}

kinda like that...
thanks
peace... \m/

jaepi 22 Practically a Master Poster

in addition, when i mount the cd-rw, it says "mount: not a directory"...and when tried openning it to windows, it says "please insert cd"...wtf do think happened???i was not able to place the -dummy option...T_T..or the media was destroyed because i was not able to delete the existing data...

jaepi 22 Practically a Master Poster

i was kind of experimenting, i burned iso file using cdrecord command, my medium was a cd-rw and it has already a data written on it...i was not able to delete that current data stored in the medium, i just burned the iso file right away...now, i cannot view my cd-rw, the files inside...what do you think happened to the medium? was it destroyed???lol...pls help me...im kinda paranoid with these things...what do you think should i in order to prevent this to happen again...thanks...

jaepi 22 Practically a Master Poster

hello there, in what way you can convert an integer to a char??
i'll use it to check if the user's input is a number, if it is a letter, it will allert him to try again and input a number...the integer will then be use for a 'for loop...thanks

jaepi 22 Practically a Master Poster

thank you for that detailed explanation..

jaepi 22 Practically a Master Poster

hi there, i just want to know what function to use in converting a char into an int
like:

char temp;
cout << "enter something";
cin >> temp;

atoi(temp);

is this the right way?

jaepi 22 Practically a Master Poster

so, if you will check if the input is a number or not, what is the appropriate function to use???

jaepi 22 Practically a Master Poster

thank you for that kind and detailed explanation...:D

jaepi 22 Practically a Master Poster

hello there...i've been using this function to know if the input of the user is a number or a letter...but it's not working...

#include <iostream>
#include <math.h>

using namespace std;

double temp2;

int main(){
    
    cout << "\n enter something";
    cin >> temp2;


    if(isnan(temp2)){
        cout << "not a number \n";
    }else{
        cout << "a number \n";
    }
    return 0;

}

did i used it correctly or not?? help

jaepi 22 Practically a Master Poster

its not working, i just press enter but it does not alert me that i placed nothing... T_T

jaepi 22 Practically a Master Poster

uhmm, what about the;

char temp[100];

how would compare to null...

btw, thank you...:D

jaepi 22 Practically a Master Poster

hello there, im new in c++...i just want to know how to compare a string to null like:

string x;
cin >> x;

if(x==NULL){

cout << "null";

}

im using this one, if(&x==0) ...but it does'nt work...
this is what my mentor told me to do...

help..thanks

jaepi 22 Practically a Master Poster

dude, at least you produced 75% of the expected 100% output in just 1 week...that's an accomplishment...i would say that you fail if you produced nothing...lol...

jaepi 22 Practically a Master Poster

haha..ok...

jaepi 22 Practically a Master Poster

how do i use it?? T_T im new in c++ dude...

jaepi 22 Practically a Master Poster

hello there, i have no idea how to check if a directory in linux already exist, can someone point me an example..pls..thanks

jaepi 22 Practically a Master Poster

thanks dude...problem solved..and oh, i followed all your advice

jaepi 22 Practically a Master Poster

hello there, i have here a program(linux based) that creates a directory then transfer files to that said directory...the problem is, im using strcat to join my bash script commands to the users inputs..now, i have a loop that concatenates the commands...
is there a way that a concatenation will refresh in a loop...here's my program...

#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <cstring>
 
using namespace std;
 
int main(){
 
char filename[50];
char directory_name[50];
char destination[50]= "cp ";
char mkdir_comm[50]= "mkdir ";
string destination_storage[50];
int number_of_files;
 
cout << "Enter directory name: ";
cin >> directory_name;
cout << "\n";
 
strcat ( mkdir_comm, directory_name);
 
(const char)*mkdir_comm;
 
system(mkdir_comm);
 
cout << "Directory successfully created: \n";
cout << "\n";
 
system("ls -l");
 
cout << "How many files do you want to transfer?:\n ";
cin >> number_of_files;
 
for(int i=0; i<number_of_files; i++){
cout << "Enter filename " << i+1 << ": ";
cin >> filename;
 
strcat( destination, filename );
strcat( destination, " ");
strcat( destination, directory_name);
 
(const char)*destination;
 
system(destination);
}
 
 
}

the cp command will ignore the commands on the 2nd loop because the concatenation does not refresh...help pls...

jaepi 22 Practically a Master Poster

If all that you are going to do is to use C++ to
make calls to commands to the CLI , why don't
you just make a script in bash with those commands?.

im going to make this as a function to my other c++ program...i was just testing it... :D

jaepi 22 Practically a Master Poster

hello there, im having trouble with the system() function...as much as possible, i would like my program to be dynamic...i created a program that will make an iso file...it will ask the user to input the directory that he would like to compress...the problem is, how do i append this to the system() function...here is my code...

_________________________________________

#include <stdlib.h>
#include <iostream>

using namespace std;


const char *directory;

int main(){

         cout << "enter directory name: ";
         cin >> directory;
         system("ls -l");
         system("mkdir"+directory);
         system("mkisofs -J -o filename.iso "+directory);

return 0;

}
______________________________________________

notice the + directory?? lol...it's obviously wrong...help pls...

jaepi 22 Practically a Master Poster

He did answer, he said he's using C++ and using the Linux Operating System.

jaepi, we don't have much information on specifically what your wanting to do and how to get this file.
Are you wanting to type in the file location and copy it to the current directory?.
Are you wanting to copy the file's contents, and write them to a file?

If you are going for the first option.
you can simply run a copy command using system() function to call the linux 'copy' command.

The second option you're looking to use "fstream"
which can be used by including. #include <fstream.h>
in your file.

You need to identify exactly HOW your wanting to get the file,
and HOW your going to store it.

If you have the methods we can give you the code for these methods.


Drag...

i think, it's near to the first option...i have created a prototype of the program...i used string instead of file, and stored it to an array of strings...

here is my code...

______________________________________________________
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <fstream>

using namespace std;


char x;
char z;
int number_of_files;
string filename;
string store_filename;
string filename_for_iso;
string file_storage[100];

inline void menu(){
        //menu
        cout << "Menu \n";
        cout << "1 - Enter file name to be compressed \n";
        cout << "2 - Exit \n" << "\n";

        cout << "Choose from the menu: ";

        cin >> x;

}

int main(int argc, char …
jaepi 22 Practically a Master Poster

>>but idk how to get the file and store it

don't know -- you will probably have to ask your teacher. Saving the file is easy but depends on whether you are writing a C or C++ program, which you failed to answer. I can only presume your program already has the data for the find in memory, or its in another file somewhere. But you need to get clarification from the instructions (please post them) or from your teacher.

im using c++ and linux...uhmmm...the user will be asked to input files by entering the file name...the files entered, if valid file, will be then stored into 1 directory...all the files inside this directory will then be compressed to an iso image file using mkisofs in linux...

jaepi 22 Practically a Master Poster

uhmmm ask for the file name then store the file itself...like for example

.....................................................
enter file name of file you would like to store: dragon.jpg
........................................................
dragon.jpg then will be stored
, but idk how to get the file and store it..

yes, it is c++ in linux...help pls...

jaepi 22 Practically a Master Poster

hello there...uhmmm, im having problems with getting the file and storing them...like for example, you ask the user to input a file then that file will be stored...how do you get that file, and where do you store them?? thanks

jaepi 22 Practically a Master Poster

thanks man, i'll try it...

jaepi 22 Practically a Master Poster

uhmm, i already have a concept, i have experienced programming in java...i know basics of c++...i have no time to study the very core because i have a deadline to catch...

jaepi 22 Practically a Master Poster

hello there...im new in c++, i need your help with this one...i want to create a program that will create an .ISO image file. the user will be asked to input all the files that he wants to compress..i just want to know what topic in c++ i will study for this program...to further elaborate, let me show to you what i mean...

__________________________

Menu:

1 - Enter file to be compressed
0 - Exit

//user enters 1

Enter filename: sex.txt
Files:

Another file (y/n)?

//user enters y

Enter filename: blah.bmp
Files:
sex.txt


Another file (y/n)?

//user enters n

your files: sex.txt, blah.bmp

Compress to ISO(y/n)?

//user enters y

enter file name for ISO: example

compressing.....

successful! - example.iso

press enter to return to main menu

__________________________

something like that...i just want to show the interface for you to know what i mean...

what do i need to study in order i can make this application?

just need your tutorials....thanks :twisted:

jaepi 22 Practically a Master Poster

hello there, im new in c++...i need to know how to access files in the hard disk...im having a priject of controling hdd using linux and c++...my task is to create a program in c++ using linux that get's a file from the hard disk, check's if the memory of the cd is full, then write the files in cd...help pls...

jaepi 22 Practically a Master Poster

im a beginner in c++ language, it is my first time to handle c++ (because im a java programmer)...part of my training in c++ is to create a dvd controller that will open, close, write and eject the media(preferably cd-rw), and of course, be able to get the files to be burn in the hard disk, in the linux environment...any of you here knows a tutorial for a poor noob like me...i need to know the commands to be used in linux and how to combine them in c++...a tutorial would be nice...thank you

jaepi 22 Practically a Master Poster

try this out http://www.linuxcommand.org/...i've been using this for 3 days and i've learned a lot already...after 2 days, i guarantee, u'll learn how to create a calculator in bash(basic calculator)..lol..

jaepi 22 Practically a Master Poster

im using GNOME too...lalalala... and i have'nt experience any difficulty using it...

jaepi 22 Practically a Master Poster

we both have the same problem..getting the data from the text field inorder for us to compare it and generate it in a function..