Posts

c - How do I return a printf statement if the user inputs nothing? -

i want execute statement based on input of user: #include <stdio.h> #include <string.h> void main() { char string_input[40]; int i; printf("enter data ==> "); scanf("%s", string_input); if (string_input[0] == '\n') { printf("error - no data\n"); } else if (strlen(string_input) > 40) { printf("hex equivalent "); } else { printf("hex equivalent "); } } when run it, , press enter, goes new line instead of saying "error - no data". what do? cannot use fgets have not gone on in class. use char enter[1]; int chk = scanf("%39[^\n]%c", string_input, enter); but string_input not have '\n' inside. test if (string_input[0] == '\n') { printf("error - no data\n"); } will have changed to, example if (chk != 2) { printf("error - bad data\n...

mysql - Queuing SQL requests PHP -

is possible queue client requests accessing database in mysql. trying concurrency management. mysql locks can used somehow not able desired outcome. effectively trying is: insert in new row select column row store value in variable the issue comes when 2 different clients insert @ same time, variables both clients store value of last insert. i worked following alternative, failed in few test runs, , bug quite evident: insert lock table select store unlock thanks! my best guess have auto-increment column , want value after inserting row. 1 option use last_insert_id() (details here , here ). if not applicable, please post more details. trying , queries being fired?

regex - How to match only odd occurrences of a character at the end of the line using grep -

for example, i'm matching odd occurrences of 'a'. "helloaaa" should match while "helloaaaa" should not match. i've tried "(aa)*a$" , without -e option on bash. your problem helloaaaa matches because of last 3 a s: helloaaaa === to avoid need make sure previous character not a : grep -e '[^a](aa)*a$' filename here i'm assuming line isn't entirely a s. if entire line can a s can use regular expression instead: grep -e '(^|[^a])(aa)*a$' filename

Calling COM method in DLL using the JNI -

i'm trying integrate third party dll using jni. i've written test class see if can call method in dll i'm getting "unsatisfiedlinkerror" error. the class looks following: public class mytest { native string configurerequest(string a, string b, string c, string d); static { system.loadlibrary("my_dll"); } @test public void quicktest(){ string result = this.configurerequest("1", "1", "1", "nocontrolbar"); system.out.println("result: " + result ); } } i have used typelibrary viewer investigate dll , can see method there (although says in package "eiacominterface.txnrequests" i'm wondering need specify package somewhere on method). can verify method parameters correct. can advise on please? thanks lot, gearoid. it looks though jacozoom possible solution above problem. in case, turns out can use soap query webserv...

sql - Relationship between Customer and Order in a Shopping Cart -

i'm making erd, can build shopping cart. i confused relationship between order , customer. if im not mistaken, customer can order many products, an order can placed 1 customer so create table orderproduct( orderproductid int primary key, productid int, quantity int ) create table orders( orderid int primary key, orderproductid int, //foregin key customerid int, date ) am correct, or mu table structure wrong? that seems fine me, need orderid in orderproduct table in order link order details order - drop orderproductid orders. some of other columns productid , customerid should foreign keys, of course. is "order" finalized order or there later invoicing step? because typically may want lock in unit price @ order (from product file @ time of order, or perhaps signed/approved quote).

c++ - catching an exception in a loaded shared library -

is catching exception thrown in loaded shared library portable? i've noticed works dlfcn.h , wonder if behaviour in general expected, example when using loadlibrary on windows instead? example code: main.cpp : #include <stdexcept> #include <cstdio> #include <dlfcn.h> typedef void(*dummy_t)(); int main() { dummy_t f; void* handle; handle = dlopen("module.so", rtld_lazy); f = (dummy_t)dlsym(handle, "modulemain"); try { f(); } catch(std::runtime_error& e) { fprintf(stderr, "caught exception: %s\n", e.what()); } dlclose(handle); } module.cpp : #include <stdexcept> extern "c" void modulemain() { throw std::runtime_error("some terrible error occured"); } yes, should work fine under windows.

html - background color of <a href> not displaying properly inside list -

Image
i'm trying create tab buttons putting hyper links inside list within unordered list. after want change color of tab when mouse hovered on it. in below code able change color green it's not covering tab, instead space exists on right , left side of link <a> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>insert title here</title> <style type="text/css"> #header ul { list-style: none; margin: 0; } #header li { float: left; padding:10px; padding-left:12px; border: 1px solid #bbb; background:red; margin: 0; } #content { clear:both; } #header { text-decoration: none; padding: 10px; text-align: center; ...