Posts

Reading in an array of 12 numbers with spaces in between each number - C programming -

i new c programming student , having trouble code working on. need ask user 12 number barcode spaces in between each value. also, need refer each individual value in array later on in code. example, if array x[12] , need use x[1] , x[2] , , other values calculate odd sum, sum, etc. below first function read in bar code using loop. assistance script of function help. #include <stdio.h> #define array_size 12 int fill_array() { int x[array_size], i; printf("enter bar code check. separate digits space >\n"); for(i=0; i<array_size; i++){ scanf("% d", &x); } return x; } you should pass array read argument , store read there. also note % d invalid format specifier scanf() . #include <stdio.h> #define array_size 12 /* return 1 if suceeded, 0 if failed */ int fill_array(int* x) { int i; printf("enter bar code check. separate digits space >\n"); for(i=0; i<array_size; i++){ ...

c - Left shifting operation on int -

on indiabix.com came across following question.as per experience level(beginner in c) output of above should 0 (10000000 << 1 00000000) came out 256,after going deeper found printing using %d supports 4 bytes output 256 instead of 0. #include<stdio.h> int main() { unsigned char = 128; printf("%d \n", << 1); return 0; } now consider following example #include<stdio.h> int main() { unsigned int = 2147483648;(bit 31 = 1 , b0 b30 0) printf("%d \n", i<<1); return 0; } when left shift above 0 output, %d supports value of int output should 0 when changed %d %ld output still 0. %ld supports values upto long int output should not 0.why getting 0 output. in first case, i promoted int , can store @ least 32767, shift calculated. result, result became 256. in second case, if unsigned int 32-bit long, calculated in unsigned int , result wraps. result, result became 0. ...

regex - How to compose regexes in code -

i writing regex irc protocol abnf message format . following short example of of regex writing. // digit = %x30-39 ; 0-9 // "[0-9]" static const std::string digit("[\x30-\x39]"); i use previous definitions form more complex ones, , gets complex, fast. having problems with, more complicated regexes, composing them: // hexdigit = digit / "a" / "b" / "c" / "d" / "e" / "f" // "[[0-9]abcdef]" static const std::string hexdigit("[" + digit + "abcdef]"); a "hexdigit" "digit" or "hex-letter". note: don't care rfc defines "hexdigit" letter (abcdef) being uppercase. going rfc says , don't plan on changing requirements. const std::regex digit(dapps::regex::digit); assert(std::regex_match("0", digit)); assert(std::regex_match("1", digit)); assert(std::regex_match("2", digit));...

java - Calling activity method in custom adapter class -

so trying refresh recyclerview in activity problem doesn't casting or way calling it. any ideas? from crashlog, appear passing applicationcontext recyclerview. instead, need pass activity context, , ensure activity implements userrview interface. a cleaner way pass context , pass userrview adapter, not have cast context userrview, , can continue pass application context if prefer. edit: replace code adapter = new customradapter(list, getbasecontext()); with adapter = new customradapter(list, this);

oracle - How to get max value out of two max values -

how can find maximum value similar fields in different tables? select max(select max(col) table1,select max(col) table2...) dual doesn't work! suggestions? you can union: select max(cols) from( select max(col) cols table1 union select max(col) cols table2)

locationmanager - how to set radius within current location android apps -

i want set radius of office. have current location code. want set radius when in radius, can use application. right current location longitude , latitude public gpstracker(context context) { this.context = context; getlocation(); } public location getlocation() { try { locationmanager = (locationmanager) context.getsystemservice(location_service); isgpsenabled = locationmanager.isproviderenabled(locationmanager.gps_provider); isnetworkenabled = locationmanager.isproviderenabled(locationmanager.network_provider); if(!isgpsenabled && !isnetworkenabled) { } else { this.cangetlocation = true; if (isnetworkenabled) { locationmanager.requestlocationupdates( locationmanager.network_provider, min_time_bw_updates, min_distance_change_for_updates, this); if (locationmanager != null) { ...

ios - how to show number of cell in table view using label -

i have 1 table view contains more many results dipslay in each cell. totally have 50 data in table view. did array , display in table view.like : var tabledata = ["thomas", "alva", "edition", "sathish", "mallko", "techno park" ..... till 50 data] what need is, have 1 label called countlabel . need display how data in tableview there? in lbel countlabel . need dipslay in label 50 datas .... because having 50 data in table view. please me how ? thanks countlabel.text = "\(tabledata.count) data"