Hi all. Is there a command in C that can delete a string contained in a longer string and then replace the deleted string with another? Big thanks to those who can help me with this.

Member Avatar
Member Avatar
+0 forum 20

Can anyone help me learn how to create a directory in C? Right now I have a program that writes to a file, and now I need to create a directory to store the file. My operating system is Windows XP. Sample programs, commands, links to tutorials will be greatly appreciated. Thank you!

Member Avatar
Member Avatar
+0 forum 1

Can anyone tell me what's wrong with my program below? I'm creating a program that writes every character(byte) from a buffer to a FILE until the number of bytes written is equal to the size of the buffer. [CODE] char *next; int character; int byteswritten = 0; next = buf; //buf is the buffer that holds the string to be written on a FILE while (byteswritten < payload) { //payload is the size of the buffer character = fputc(*next, fp); //fp is the FILE where the contents of buf will be written to byteswritten++; next++; } [/CODE] The problem of …

Member Avatar
Member Avatar
+0 forum 5

Hi all. I'd like to ask for a way to store a MySQL table content of type VARCHAR to a CHAR variable in C. The MySQL table has three columns: ID (int), Name (varchar(22)), Salary (int). My C program should ask the user to input an ID number, and depending on the input value, the program should look up in the table whose Name it belongs to, then store that name on a variable of type CHAR. I tried doing it but an error that says "Incompatible variable types" is returned when I compile the program. The function of my …

Member Avatar
Member Avatar
+0 forum 1

Hi, I wanna traverse inside the file system by using threads and processes.My program has to assume the first parameter is either given as "-p" which offers a multi-process application or "-t" which runs in a multi-threaded way. The second parameter is the pathname of a file or directory. If my program gets the path of a file, it should print out the size of the file in bytes. If my program gets the path of a directory, it should, in the same way, print out the directory name, then process all the entries in the directory except the directory …

Member Avatar
+1 forum 0

Hi, What command/technique is needed in a C program to receive image bytes through socket programming from an HTTP response? I want to develop a program that requests for an image from a server, then upon receiving the bytes comprising the image, it should write these bytes into a newly created file such that an image file is created. The image is of .jpg format. I really don't know how to create a program that receives and stores bytes through sockets so I hope someone here knows how to do it. So far, what I know is how to receive …

Member Avatar
Member Avatar
+0 forum 1

Hello all. I've previously created a working socket program in C in a 32-bit machine and now I have to transfer it to a 64-bit machine. May I ask if there is anything I have to change in my program to make it work in a 64-bit machine? I did some research on how to do it and from what I've learned, it seems like I'll have no problem transferring the program and make it work except for one function I used. I used [B]htons[/B] in my program in the 32-bit machine and it seems that it has a 64-bit …

Member Avatar
Member Avatar
+0 forum 1

Hi everyone! I recently created a MySQL table that has three columns: (1) integer ID (2) integer num1 (3) integer num2 Now, I have a C program that waits for the user to input an integer ID and when there is an input, the corresponding num1 and num2 in the 2nd and 3rd columns in the table will be retrieved. However, it only assumes that the input is in the table. I don't know yet how to include an error checking part in the code that will determine whether the inputted value is contained in the table or not. If …

Member Avatar
Member Avatar
+0 forum 3

Hello all. I'm trying to compile a socket program in DevC++ but everytime I do it I get a lot of linker errors like these: [CODE] [Linker error] undefined reference to `WSAStartup@8' [Linker error] undefined reference to `htons@4' [Linker error] undefined reference to `inet_pton' [Linker error] undefined reference to `socket@12' [/CODE] I have previously run the socket program successfully in Linux but I have to export it to WindowsXP, and I must admit I'm relatively new to programming in WindowsXP. These are the header files I used in the WindowsXP version: [CODE] #define WIN32_LEAN_AND_MEAN #include <windows.h> //#include <winsock.h> #include <winsock2.h> …

Member Avatar
Member Avatar
+0 forum 4

Hi everyone! I'm transferring my C program that I created from Linux to WindowsXP. I would like to know what I need to download/install in Windows in order to compile and successfully run the program? Also, will I need to change some parts of the source code? I used socket programming and MySQL for the C program. Thanks!

Member Avatar
Member Avatar
+0 forum 7

Hi guys, I am coding the solution to K & R 2nd edition. I compare my solutions with the C answer book. Sometimes i feel my code is shorter but whether it is better and whether it confirms to good coding standards is what i am worried about. So i request the Top coders/Gurus/C Pundits here to kindly take a look at the code and give their valuable comments. For starters here is my code for Ex 4-3 Pg 79( Extend the Polish calculator to include negative numbers) [B][U]My Code :[/U][/B] [CODE] /* getop : get next operator or numeric …

Member Avatar
+0 forum 0

Hello all. I created a C program that used MySQL in Linux and now I'm transferring the program to Windows. I would like to ask what software do I need to download/install in Windows to be able to compile and run the program there? Also, when the program is already in Windows, do I need to change the way it accesses the MySQL database? Or is it the same in Linux and Windows in accessing the MySQL database through C programming? Thanks! The Windows I have is Windows XP

Member Avatar
Member Avatar
+0 forum 2

Hi, I'm kinda new to using MySQL,I just downloaded sqlite3 for my Linux. Can anyone give me some links to tutorials/sample codes that use MySQL and C as a programming language? Thank you

Member Avatar
Member Avatar
+0 forum 1

Hi everyone. I'm using sqlite3 in Linux and I currently have a problem. I have a database and 2 tables in it: db1 and db2. db1 has 3 columns: empID, empName, empAddr. db2 has just 1 column: empID and its value is set to 0 by default. I created a C program that continuously polls the 2nd database db2 for any changes in the value of empID. Depending on the new value of empID in db2, the program fetches the corresponding info from db1. For example, if the value of empID in db2 is changed to 1, the program looks …

Member Avatar
Member Avatar
+0 forum 7

Hi everyone. Is there a way to use w3m in a C program such that when we run the program it will automatically "run" w3m instead of us typing it in the terminal in linux? Thanks

Member Avatar
Member Avatar
+0 forum 1

I created a C program that will make a connection to a website. I can compile it with no errors at all but when I run it, I still can't create a connection to my specified website. The errors that are shown in the terminal are: client: connect: Connection timed out client: connect: Connection timed out client: failed to connect Right now I can't find where the error might be. So may I ask anyone if there is something erroneous/missing in the program? Thank you. My program looks like the one below: [CODE] // get sockaddr, IPv4 or IPv6: void …

Member Avatar
Member Avatar
+0 forum 5

Can anyone help me improve my source code below? I tried fixing it but apparently, there's not much success. [CODE] #define NUM_THREADS1 1 void *go_to_website2(void *program); void *go_to_website1(void *program) { char* str[3]; str[0] = (char *)program; str[1] = "http://www.google.com"; //supposedly 2nd website to go to str[2] = '\0'; char* new_prog = "firefox"; pthread_t th; int rc2; rc2 = pthread_create(&th, NULL, go_to_website2, (void *)new_prog); //2nd thread created pthread_join(th, NULL); //wait for the second thread th to be finished execvp(str[0], str); //go to 2nd website (google.com), unsuccessfully opened } void *go_to_website2(void *program) { char* str2[3]; str2[0] = (char *)program; str2[1] = "http://www.yahoo.com"; …

Member Avatar
Member Avatar
+0 forum 8

Hi everyone! I just want to ask, how do I use socket programming in C to open/go to web sites? I want to create a program that should look like this: the program asks for an integer input from the user and depending on the input number, the program invokes and tries to connect to a specific website. For example, if the input is 1, the program will try to connect to htttp://www.yahoo.com and if the input is 2, the program will try to connect to [url]http://www.google.com[/url]. The websites will be pre-determined, meaning if the input is 1, the program …

Member Avatar
Member Avatar
+0 forum 3

Hi everyone! Does anyone here know how to create a C program that will open a web browser depending on the user input? For example if the user inputs the integer 1, the web browser will be opened and will go to 'http://www.daniweb.com', when the input is 2, 'http://www.google.com' will be opened, and so on. The websites that will be opened will be pre-determined, meaning it will be set in the program source code that everytime the input is 1 the web browser will go to 'http://www.daniweb.com' only; no random choosing of websites will be done. Replies and/or links to …

Member Avatar
Member Avatar
+0 forum 12

Can anyone help me improve my source code below? I tried fixing it but apparently, there's not much success. [CODE] #define NUM_THREADS1 1 void *go_to_website2(void *program); void *go_to_website1(void *program) { char* str[3]; str[0] = (char *)program; str[1] = "http://www.google.com"; //supposedly 2nd website to go to str[2] = '\0'; char* new_prog = "firefox"; pthread_t th; int rc2; rc2 = pthread_create(&th, NULL, go_to_website2, (void *)new_prog); //2nd thread created pthread_join(th, NULL); //wait for the second thread th to be finished execvp(str[0], str); //go to 2nd website (google.com), unsuccessfully opened } void *go_to_website2(void *program) { char* str2[3]; str2[0] = (char *)program; str2[1] = "http://www.yahoo.com"; …

Member Avatar
Member Avatar
+0 forum 9

The End.