Search Results

Search found 15210 results on 609 pages for 'technical writing'.

Page 28/609 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • Writing a new line to file in PHP

    - by James P
    My code: $i = 0; $file = fopen('ids.txt', 'w'); foreach ($gemList as $gem) { fwrite($file, $gem->getAttribute('id') . '\n'); $gemIDs[$i] = $gem->getAttribute('id'); $i++; } fclose($file); For some reason, it's writing \n as a string, so the file looks like this: 40119\n40122\n40120\n42155\n36925\n45881\n42145\n45880 From Google'ing it tells me to use \r\n, but \r is a carriage return which doesn't seem to be what I want to do. I just want the file to look like this: 40119 40122 40120 42155 36925 45881 42145 45880 Thanks.

    Read the article

  • SOS: AudioFormat when writing to file in FreeTTS

    - by user330793
    Very annoying problem. I have developed a freeTTS application of the freetts class that write captured audio to file however I am having some very annoying problems. When setting the audio player to singlefileaudio player I try to also set the audioformat with my own default values for sampleRate, sampleSizeInBits, channels, signed and bigEndian. Now I access AudioPlayer.get methods to show these values in runtime just to ensure they are set to what I set them and they match those values. However when file writing completes and I check the properties of the resulting wave file, they are set to the audioPlayer default settings. Normally this will be fine except I have to read the files into another application which has fixed audio property settings so I always get a resulting output that sounds like am fast forwarding the sound and listening to it at the same time. Obviously because of the different sampling rates. I need help please. Thanx, Henry

    Read the article

  • Writing a telnet client

    - by MAC
    HI, I have a device that exposes a telnet interface which you can log into using a username and password and then manipulate the working of the device. I have to write a C program that hides the telnet aspect from the client and instead provides an interface for the user to control the device. What would be a good way to proceed. I tried writing a simple socket program but it stops at the login prompt. My guess is that i am not following the TCP protocol. Has anyone attempted this, is there an opensource library out there to do this? Thanks

    Read the article

  • C++ ofstream cannot write to file....

    - by user69514
    Hey I am trying to write some numbers to a file, but when I open the file it is empty. Can you help me out here? Thanks. /** main function **/ int main(){ /** variables **/ RandGen* random_generator = new RandGen; int random_numbers; string file_name; /** ask user for quantity of random number to produce **/ cout << "How many random number would you like to create?" << endl; cin >> random_numbers; /** ask user for the name of the file to store the numbers **/ cout << "Enter name of file to store random number" << endl; cin >> file_name; /** now create array to store the number **/ int random_array [random_numbers]; /** file the array with random integers **/ for(int i=0; i<random_numbers; i++){ random_array[i] = random_generator -> randInt(-20, 20); cout << random_array[i] << endl; } /** open file and write contents of random array **/ const char* file = file_name.c_str(); ofstream File(file); /** write contents to the file **/ for(int i=0; i<random_numbers; i++){ File << random_array[i] << endl; } /** close the file **/ File.close(); return 0; /** END OF PROGRAM **/ }

    Read the article

  • Writing a C Macro

    - by shaharg
    Hi, I have to write a macro that get as parameter some variable, and for each two sequential bits with "1" value replace it with 0 bit. For example: 10110100 will become 10000100. And, 11110000-00000000 11100000-100000000 I'm having a troubles writing that macro. I've tried to write a macro that get wach bit and replace it if the next bit is the same (and they both 1), but it works only for 8 bits and it's very not friendly... P.S. I need a macro because I'm learning C and this is an exercise i found and i couldn't solve it myself. i know i can use function to make it easily... but i want to know how to do it with macros. Thanks!

    Read the article

  • iPhone 4.0 Screen Resolution and writing robust code...

    - by Magic Bullet Dave
    Does anyone know what will happen with existing apps when they run on the iPhone 4.0 in terms of the new screen resolution? I am assuming, just like developing for the iPad that there should be no hard coded screen resolutions in your code. I'd also like advice on the best way of writing robust code to work well on any device. For instance, detecting the screen resolution is not enough - on the iPad the screen is physically bigger so you can display more items on it. On the new iPhone the screen is the same physical size but higher resolution, so the likely thing is that you wont want to display more items, just higher resolution versions of them. Any help would be useful, Regards Dave EDIT: I have read the other similar posts, I guess what I really would like to know is what is the recommended way to write code for all App Store devices in a robust way so they a) all work b) make best use of the device.

    Read the article

  • Help writing getstring function

    - by volting
    Im having some trouble writing a getstring function, this is what I have so far. Regards, V const char* getstring() { char *buffer; int i = 255; buffer = (char *)malloc(i*sizeof(char)); *buffer = getchar(); while ( *buffer != '\n' ) { buffer++; *buffer = getchar(); } *buffer = '\0'; const char* _temp = buffer; return _temp; } int main() { char* temp = getstring(); for ( ;temp++ ; *temp != '\0') { printf("%c", *temp); } return 0; }

    Read the article

  • How do I get started writing a .Net-wrapper around C++ Omniorb-stubs

    - by Superfisi
    Hello there, my job is to access a CPRBA-server-application from .NET 3.5. After evaluating projets like IIOP.Net (undefined state) and products like VisiBroker (expensive) I'd like to do it "by myself" and write a .Net-Wrapper around C++-Stubs generated my Omniidl (the Omniorb IDL to C++ generator). This means writing some kind of layer of managed code (CLI) around the unmanaged C++ code. My question is: Has anyone experience in this topic? I honestly don't know how to do it the best way. Right now I plan to create a managed class for every unmanaged class, each managed class itself has a member to an instance of the unmanaged class, which is not garbage-collected. Is this the right way to do it or am I on the wrong path? Thanks in advance!

    Read the article

  • Writing to the middle of the file (without overwriting data)

    - by Andreas Bonini
    In windows is it possible through an API to write to the middle of a file without overwriting any data and without having to rewrite everything after that? If it's possible then I believe it will obviously fragment the file; how many times can I do it before it becomes a serious problem? If it's not possible what approach/workaround is usually taken? Re-writing everything after the insertion point becomes prohibitive really quickly with big (ie, gigabytes) files. Note: I can't avoid having to write to the middle. Think of the application as a text editor for huge files where the user types stuff and then saves. I also can't split the files in several smaller ones.

    Read the article

  • Writing shorter code/algorithms, is more efficient (performance)?

    - by Carlos
    After coming across the code golf trivia around the site it is obvious people try to find ways to write code and algorithms as short as the possibly can in terms of characters, lines and total size, even if that means writing something like: n=input() while n>1:n=(n/2,n*3+1)[n%2];print n So as a beginner I start to wonder whether size actually matters :D. It is obviously a very subjective question highly dependent on the actual code being used, but what is the rule of thumb in the real world. In the case that size wont matter, how come then we don't focus more on performance rather than size?

    Read the article

  • Reading and writing to SysV shared memory without synchronization (use of semaphores, C/C++, Linux)

    - by user363778
    Hi, I use SysV shared memory to let two processes communicate with each other. I do not want the code to become to complex so I wondered if I really had to use semaphores to synchronize the access to the shared memory. In my C/C++ program the parent process reads from the shared memory and the child process writes to the shared memory. I wrote two test applications to see if I could produce some kind of error like a segmentation fault, but I couldn't (Ubuntu 10.04 64bit). Even two processes writing non stop in a while loop to the same shared memory did not produce any error. I hope someone has experience concerning this matter and can tell me if I really must use semaphores to synchronize the access or if I am OK without synchronization. Thanks

    Read the article

  • Async stream writing in a thread

    - by blez
    I have a thread in which I write to 2 streams. The problem is that the thread is blocked until the first one finishes writing (until all data is transferred on the other side of the pipe), and I don't want that. Is there a way to make it asynchronous? chunkOutput is a Dictionary filled with data from multiple threads, so the faster checking for existing keys is, the faster the pipe will write. void ConsumerMethod(object totalChunks) { while(true) { if (chunkOutput.ContainsKey(curChunk)) { if (outputStream != null && chunkOutput[curChunk].Length > 0) { outputStream.Write(chunkOutput[curChunk]); // <-- here it stops } ChunkDownloader.AppendData("outfile.dat", chunkOutput[curChunk], chunkOutput[curChunk].Length); curChunk++; if (curChunk >= (int) totalChunks) return; } Thread.Sleep(10); } }

    Read the article

  • Java: file write on finalize method

    - by sowrov
    In my understanding a singleton object will destroy only when the application is about to terminate. So in C++ I write a Singleton class to log my application and in that Singleton logger's destructor I log the time when my application was terminated. Things worked perfectly in C++. Now I want to have that same logger in Java, as in java there is no destructor so I implemented the finalize method for that singleton logger. But it seem that finalize method actually never get called. So, I add that System.runFinalizersOnExit(true); line, somewhere in my code (though I know it is deprecated) and that finalize method get called every time before termination of the app. But still there is a problem! If I try to write anything on file in that finalize method, It does not work, though System.out work without any problem! :( Can you guys help me on this problem? Here is a sample code of what I am try to do: Singleton Logger Class: public class MyLogger { FileWriter writer; private MyLogger() { try { this.writer = new FileWriter("log.txt"); } catch (IOException ex) { } } public static MyLogger getInstance() { return MyLoggerHolder.INSTANCE; } private static class MyLoggerHolder { private static final MyLogger INSTANCE = new MyLogger(); } @Override protected void finalize () { try { super.finalize(); System.out.println("Here"); //worked correctly. this.writer.write(new Date().toString()+System.getProperty("line.separator")); this.writer.write("End"); this.writer.flush(); //does not work! this.writer.close(); } catch (Throwable ex) { } } public synchronized void log(String str) { try { this.writer.write(new Date().toString()+System.getProperty("line.separator")); this.writer.write(str+"\n"); this.writer.flush(); } catch (IOException ex) { } } } Main: public class Main { public static void main(String[] args) { System.runFinalizersOnExit(true); MyLogger logger = MyLogger.getInstance(); logger.log("test"); } }

    Read the article

  • Improve performance writing 10 million records to text file using windows service

    - by user1039583
    I'm fetching more than 10 millions of records from database and writing to a text file. It takes hours of time to complete this operation. Is there any option to use TPL features here? It would be great if someone could get me started implementing this with the TPL. using (FileStream fStream = new FileStream("d:\\file.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite)) { BufferedStream bStream = new BufferedStream(fStream); TextWriter writer = new StreamWriter(bStream); for (int i = 0; i < 100000000; i++) { writer.WriteLine(i); } bStream.Flush(); writer.Flush(); // empty buffer; fStream.Flush(); }

    Read the article

  • Security when writing a PHP webservice?

    - by chustar
    I am writing a web service in PHP for the first time and had ran into some security problems. 1) I am planning to hash passwords using md5() before I write them to the database (or to authenticate the user) but I realize that to do that, I would have to transmit the password in plaintext to the server and hash it there. Because of this I thought of md5()ing it with javascript client side and then rehashing on the server but then if javascript is disabled, then the user can't login, right? 2) I have heard that anything that when the action is readonly, you should use GET but if it modifies the database, you should use POST. Isn't post just as transparent as GET, just not in the address bar?

    Read the article

  • Writing .NET in dynamic language?

    - by tillda
    I'm confused by the possibility of writing .NET in dynamic languages, such as (Iron)Ruby. Particularly, I've seen code in IronRuby that used generics (...foo[String]), but I'm not aware of this feature in Ruby as it seems nonsense to me in dynamic languages. So, when I write .NET app in IronRuby, how is it with type safety and compilation? I thought that it is just as dynamic as Ruby everywhere else. I thought that if the Ruby syntax is OK all the type checking would be done at the runtime. Also, as far as I know, .NET itself is type-oriented - there are classes that heavily utilize the mentioned generics. How is this handled? And what about delegates? In dynamic languages I can have almost function-spaghetti and sometimes, its just fine (like hacking UI in javascript). Or do I have to care even about generic delegates?

    Read the article

  • Writing Ruby Libraries - hiding methods from outside the module

    - by JP
    Hi all, I'm writing a Ruby library which has a module with a bunch of classes inside it. Many of these classes need to be usable and modifiable by calling scripts, but I don't want (some of) the initializers to be visible/callable: module MyLib class Control def initialize # They can use this end def do_stuff Helper.new('things') end end class Helper # Shouldn't be visible def initialize(what) @what = what end def shout @what end end end c = MyLib::Control.new h = c.do_stuff p h.shout # => "things" # ^ All of this is desired # v This is undesirable p MyLib::Helper.new('!') # => <MyLib::Helper @what='!'> If it's a simple thing, then I'd also appreciate the generated RDoc not even include the .new method for the Helper class either. Any ideas? Thanks for reading!

    Read the article

  • Simple C++ container class that is thread-safe for writing

    - by conradlee
    I am writing a multi-threaded program using OpenMP in C++. At one point my program forks into many threads, each of which need to add "jobs" to some container that keeps track of all added jobs. Each job can just be a pointer to some object. Basically, I just need the add pointers to some container from several threads at the same time. Is there a simple solution that performs well? After some googling, I found that STL containers are not thread-safe. Some stackoverflow threads address this question, but none that forms a consensus on a simple solution.

    Read the article

  • Writing Strings to files in python

    - by Leif Andersen
    I'm getting the following error when trying to write a string to a file in pythion: Traceback (most recent call last): File "export_off.py", line 264, in execute save_off(self.properties.path, context) File "export_off.py", line 244, in save_off primary.write(file) File "export_off.py", line 181, in write variable.write(file) File "export_off.py", line 118, in write file.write(self.value) TypeError: must be bytes or buffer, not str I basically have a string class, which contains a string: class _off_str(object): __slots__ = 'value' def __init__(self, val=""): self.value=val def get_size(self): return SZ_SHORT def write(self,file): file.write(self.value) def __str__(self): return str(self.value) Furthermore, I'm calling that class like this: def write(self, file): for variable in self.variables: variable.write(file) I have no idea what is going on. I've seen other python programs writing strings to files, so why can't this one? Thank you very much for your help.

    Read the article

  • need help in writing ant target

    - by magic1234
    I am new to writing ant targets. I've to pass 3 arguments from the command line to java program. All these can be optional and can have spaces. How can i do that using ant target. I tried using but if it delimits the arguments by space. So, if my first argument has space then it takes the word after space as second argument. I also tried using It takes spaces but makes the arguments mandatory. Im my java code, i've to set default values for these arguments if any of these is missing. How can i do that.

    Read the article

  • VBscript and CMD writing into a text file

    - by Effected
    I am writing a script that executes and write everything to the file here is example, I stored the complete command in the variable 'Command' , Command = "ftp ftp.xyz.com 21 " & vbCRLF and then executing it in command prompt, shell.Run "%comspec% /c FTP " & Command & " > " & E:/abc.txt, 0, TRUE but when this program execute it won't write anything to the text file because this is an incomplete command, this command on execution prompt user to input username and password of FTP, how can i do this , that my programm automatically input username and password when prompt and then write everything to file ?

    Read the article

  • Writing to a file in Unicode

    - by Lefteris
    I am having some problems writing to a file in unicode inside my c program. I am trying to write a unicode Japanese string to a file. When I go to check the file though it is empty. If I try a non-unicode string it works just fine. What am I doing wrong? setlocale(LC_CTYPE, ""); FILE* f; f = _wfopen(COMMON_FILE_PATH,L"w"); fwprintf(f,L"???"); fclose(f); Oh about my system: I am running Windows. And my IDE is Visual Studio 2008.

    Read the article

  • [C++] Needed: A simple C++ container (stack, linked list) that is thread-safe for writing

    - by conradlee
    I am writing a multi-threaded program using OpenMP in C++. At one point my program forks into many threads, each of which need to add "jobs" to some container that keeps track of all added jobs. Each job can just be a pointer to some object. Basically, I just need the add pointers to some container from several threads at the same time. Is there a simple solution that performs well? After some googling, I found that STL containers are not thread-safe. Some stackoverflow threads address this question, but none form a consensus on a simple solution.

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >