Hello there, I'm having trouble finding the corresponding linux function of win32's SetFilePointer(), ReadFile() and WriteFile(). Do anybody here have any ideas on what to replace or use. Thanks. :)
Hello there, I'm having trouble finding the corresponding linux function of win32's SetFilePointer(), ReadFile() and WriteFile(). Do anybody here have any ideas on what to replace or use. Thanks. :)
Any of you here knows the corresponding structure of CRITICAL_SECTION in linux? thanks.
Thank you sir. :)
Hello there. I just want to ask some simple explanation about multithreading in this situation.
Suppose I have two CD/DVD drives and an applicaton that enables me to control these two drives. This application uses multithreading. How would this thread be implemented or what is the help that this multithreading could do to my application. Thanks :)
Thanks!
thank you sir, i'll try it.
Hello there, I have here a problem with the function open(). Since its first parameter asks for a char*, how would i convert wchar_t* to char* if my program asks for a wchar_t* as its path rather than char*?
Thank you very much sir, it worked.
Additional question. Does ifstream reads a space as a beginning of a new line?
Hello there, I have here a program that reads a txt file taking each word in three columns separated by a comma and storing it to a vector. It has a filter that whenever it sees a comma, it seperates the word from each other. My problem is, whenever I type a phrase or a sentence in a line, the space is considered to a be a beginning of a new line in which ruining the output and producing a run time error. Here's my code and my input txt file.
CODE:
#include <iostream>
#include <vector>
#include <cctype>
#include <string>
#include <fstream>
#include <iomanip>
#include <stdlib.h>
#include <windows.h>
using namespace std;
vector<string> split_String(const string& str) //reading csv file
{
vector<string> vStr;
int i = 0;
while (i != str.size())
{
while (i != str.size() && str[i]==',' ){
i++;
}
int j = i;
while (j != str.size() && str[j]!=',' ){
j++;
}
if (i != j)
{
vStr.push_back(str.substr(i, j - i));
i = j;
}
}
return vStr;
}
int main()
{
vector<string> vCode;
vector<string> vWord;
vector<string> vFile;
std::string my_File("sample.txt");
ifstream inFile(my_File.c_str());
std::string str1;
const char *pStorage = 0;
int arr = 0;
if (!inFile) //if file cannot be read
{
cout << "Unable to open file";
exit(1);
}
else
{
while(!inFile.eof()) // reading the file line by line
{
inFile >> str1;
pStorage = str1.data();
cout << "BEFORE = " << pStorage << endl;
vector<string> vOutput = split_String(pStorage);
for (int i = 0; i < vOutput.size(); i++) …
Hello there, is there anybody here who has experienced programming in Multimedia Commands with c++? I have here an application in Linux that controls the cd/dvd drive using SCSI2 - Multimedia Commands set. I have a bit of bewilderment. Right now I'm debugging an error in opening the drive tray and with the prevention of the removal of the media commands. Now here's my questions:
- Once the drive is unlocked and you unlock it before you send the command of open tray, would it produce an error or would it considered to be an error? <-(I've been producing errors in doing this and this is one of my theories, I just want to confirm here if it's true)
- I have already locked the cd/dvd drive, but why is it that the drive can be opened whenever I press the eject button in the drive? And why is it that the drive won't open when I use my own command of open tray? (I just want to know the difference of pressing the eject button of the drive with sending the open tray
command)
I'm kind of confused. I've been looking for it in the MMC manual, but I was not able to find a convincing answer. Thank you. :)
Hello there, do any of you here know any interface that will write to a file in MFC like the ofstream. thanks :)
Thank you very much sir. :)
Hello there, is there a corresponding function or struct in linux for the the struct SystemTime in windows? Thanks! :)
Thank you sir. :)
I think this version sir. I'm looking for the corresponding Linux version of this GetTickCount() function.
http://msdn2.microsoft.com/en-us/library/ms724408.aspx
Thank you very much for the enlightenment.
hello there, do anybody here have an idea of the Linux version of the GetTickCount() function. thanks! :)
yes, i did it before you told me. here's my code sir.
#include <iostream>
using namespace std;
int main(){
int x,y,z;
for(int i =0; i<=2; i++){
x = (unsigned char) ((i>>24) & 0xff ));
y = (unsigned char) ((i>>16) & 0xff ));
z = (unsigned char) ((i>>8) & 0xff ));
}
cout << "x=" << x << endl;
cout << "y=" << y << endl;
cout << "z=" << z << endl;
return 0;
}
i placed that line dude...
output:
x=
y=
z=
i did, but it showed nothing.. T_T
suppose i will do this stuff
int x, y, z;
for(int i =0; i<=2; i++){
x=(unsigned char)((i>>24) & 0xff));
y=(unsigned char)((i>>16) & 0xff));
z=(unsigned char)((i>>8) & 0xff));
}
what do you think will happen to the values of x, y and z?
hello there, can anyone here explain to me and an explanation on the usage of these operators (<< and >>) or point me to any site that explains it very well... thank you... :)
thanks guys! :)
hello there, i just want to ask what is the difference of having your IDE CD/DVD drive in /dev/sd0 rather than in /dev/hda? my friend and i have the same kernel version and distro (Ubuntu). the only difference is, my hard drive is detected in the file system of /dev/hda and his is in /dev/sd0. what do you think is the reason? thanks.
Hello there, I'm creating a cd writer application. As of now, I was able to create a data burning application for cd-r/rw. I'm having trouble finding the code block for writing audio cd. I'm using cdrom.h and the command for writing data is CGC_DATA_WRITE together with GPCMD_WRITE_10, I looked for any audio writing command but I was not able to find. Is there anyone here who has experience writing cd writers apps to help me. Thanks. In case you ask why am I "reinventing the wheel", it's my project.
hello there, can someone here with a kind heart to explain to me how the struct request_sense sense errors when you use the cdrom.h. thanks!
Thank you very much sir. :)
I committed a typographical error in visiting a site. I was directed to this site -> http://www.freewebs.com/gulong which has junk characters that looks like a virus T_T. I scanned all my drives, but no viruses where found. I'm paranoid because the server's firewall might have detected, if there was, a virus...Can someone help me pls...BTW I have no language support installed in my windows xp, it might be a foreign site but I just want to make sure with experts here if the site is safe so that I can prepare myself and do something. Thanks.
@thekashyap - Oh, I see. I'm actually dealing with the cd/dvd-rw drive and the media inside it. As what I have read, the function GetDiskFreeSpaceEx( ) has a parameter that deals with the free space in the cd/dvd media, but I'm not quite sure of that. I saw a function which is,I think, quite similar to fstat(), it's statvfs and fstatvfs. I tried both but they still give the same 0 value on the size and the free blocks. *sigh*.
@Salem - I'll try these one dude.
@thekashyap and Salem - Thanks! :)
In addition, I'm getting a 0 in both the size and the free blocks. T_T
I tried to used the function to my hard drive but it's giving me a -1 return. I checked the mode it's both readable and writable for the root and ordinary users. T_T. *sigh*. What do you think is the problem? Here's my code.
//#include <sys/vfs.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <iostream>
using namespace std;
struct stat buffer;
int status;
off_t size;
blkcnt_t fblock;
int main(){
size = buffer.st_size;
fblock = buffer.st_blocks;
int fildes = open("/dev/hda", O_RDWR);
status = fstat(fildes, &buffer);
cout << "size: " << size << endl;
cout << "free blocks: " << fblock << endl;
cout << status << endl;
return 0;
}
Hello there, anyone here knows what is the function or library in Linux that corresponds to the win32 functions/library given bellow.
library
- #include <Windows.h>
functions
- GetDiskFreeSpaceEx()、GetFileAttribute()、GetModuleFileName()、GetFileVersionInfoSize()、GetFileVersion( )
Thank you!
ive learned it the hardway. from scratch i have to do intermediate programming modules in a day or two. (the basics are just inserted during research time) <- this is not a good idea
Same experience with me, which is veeeerrryy baadd...
I have found the corresponding header file for scsipt.h in linux... it's cdrom.h...:D
Hello there, is there a scsipt.h version for Linux? I've been looking for this because I really need that header file.
Oh, I see. Thanks for that detailed explanation. :)
This code is for Linux so it'll be in gcc compiler. Oh I see. Btw, how do these debug codes inside the directives work? I mean, why does it have to use the va_ family of functions? *sigh*
Hello there, just a question, what do you think is the purpose of this flag to this block of code...
void CDriveControl::Trace(bool bAt, char *lpszFormat, ...)
{
#ifdef _DEBUG
va_list args;
va_start(args, lpszFormat);
printf(lpszFormat, args);
if( bAt) {
fflush( stdout);
}
va_end(args);
#endif
}
I've been wondering, why do you have to check if the _DEBUG flag is defined?
Ahhh...Thanks! :)
I was just wondering how these bitwise operators work given only the variables. If it manipulates the memory address. Thanks again.
Try using a dry run method..
Convert the variable values in binary and then use the XOR oerator on them.U 'll be surprized to see the results..
I've already tried that before I placed this post. I'm just curious on how the compiler manipulates the swapping of variables. What is it's basis? The memory location of the entire variable? lol...Funny me.
I've been having troubles understanding some of the hardware stuffs. *sigh*. No choice, I don't want to lose this opportunity of having a nice project. I have a question. Given 1 week, will you be able to document the whole code and trace it? I mean, it is my first time to handle c++ and linux. Or am i just too slow?
There some product endorsers that creates fake accounts then use it to promote their products by spamming you gazzillions of bulletins and comments. I have a friend that uses a bot that is in charge of adding friends to spread the name of their band. tsk tsk.
I've been studying c++ for the past 2 months and now I'm studying a code that deals with accessing the dvd-driver using scsi-3 multi media commands. I'm currently researching about the related topics, and one of it is the spti. :)
Oh I see, I'm sorry if I posted the thread here. Because I really don't know specifically it implies so I assumed that it is somehow related to c++. Thank you.
Hello there, I've been googling around about the definition of SPTI (SCSI Pass-Through Interface). It is somehow related to c++ since it is use to manipulate a drive using the c++ language. Is someone here knows the definition of SPTI, or simply explain to me briefly what it does. Thank you.
One last question. How would you know the certain flag of a variable. Like for example, I have here two variables of type int.
int a = 9, b = 3;
I will swap the contents of the variables using the XOR(^) operator.
a ^= b;
b ^= a;
a ^= b;
How did the swapping happened? Are these variables, once initialized, may have a default flag? Or, the swapping were done by manipulating the memory location using the XOR(^) bitwise operator? Thank you.
Thanks, I'm still having a problem understanding this example program I'm examining (actually it's a dvd-driver controller). But I now understand how these flags and the operators work. Thank you again!
Oh, I see. So these variables (DC_ST_DISK_IN, DC_ST_TRAYCLOSE, DC_ST_WRITING) are bit flags. By the way, their values are in the form of this one (0x0001, 0x0002 etc) <- is this binary? how would they be compared with each other using the "|" bitwise operator? Thank you.