Search Results

Search found 6123 results on 245 pages for 'unsigned char'.

Page 191/245 | < Previous Page | 187 188 189 190 191 192 193 194 195 196 197 198  | Next Page >

  • How to cin Space in c++?

    - by Narek
    Say we have a code: int main() { char a[10]; for(int i = 0; i < 10; i++) { cin>>a[i]; if(a[i] = ' ') cout<<"It is a space!!!"<<<endl; } return 0; } How to cin a Space symbol from command line? If you write space, program ignores! :(

    Read the article

  • Replacing the end of the line by SED in makefile

    - by Masi
    How can you append to the end of a line by SED controlled by makefile? I run paste -d" " t.tex tE.tex | sed 's@$@XXX@' > tM.tex where the problem is in the use of the mark $ for the end of the line. I get #paste -d" " t.tex tE.tex | sed -e s/" "/\\\&/g | sed -r "s/XXX/" > tM.tex sed: -e expression #1, char 10: unterminated `s' command make: *** [all] Error 1 I have the command just after the "all:" tag in my makefile which contains only the two lines. The parameters -n and -e do not help here. The command works as expected run when it is run directly in terminal.

    Read the article

  • Printing escape character

    - by danutenshu
    When I am given "d""\"/""b", I need to print out the statement character for character. (d, b, a slash, a backslash, and 5 quotes) in C++. The only errors that show now are the lines if(i.at(j)="\\") and else if(i.at(j)="\""). Also, how should the outside double apostrophes be excluded? #include <iostream> #include <cstdlib> using namespace std; int main (int argc, const char* argv[] ) { string i= argv[1]; for (int j=0; j>=sizeof(i)-1; j++) { if(i.at(j)="\\") { cout << "\\"; } else if(i.at(j)="\"") { cout << "\""; } else { cout << i.at(j); } } return 0; }

    Read the article

  • GCC fatal error: stdio.h: No such file or directory

    - by user2615799
    I'm trying to compile a program in C on OS X 10.9 with GCC 4.9 (experimental). For some reason, I'm getting the following error at compile time: gcc: fatal error: stdio.h: No such file or directory I then tried a simple Hello World program: #include <stdio.h> int main(int *argc, const char *argv[]) { printf("Hello, world!"); return 0; } Again, upon running gcc -o ~/hello ~/hello.c, I got the same error. I'm using an experimental version of gcc, but it seems implausible that there would be a release which generated errors upon importing stdio. What could be causing this issue, and how can it be fixed?

    Read the article

  • how to listen to Enter button when using JOptionPane.showOptionDialog

    - by MemoryLeak
    I use: char[] password = null; JPasswordField jpf = new JPasswordField(30); java.lang.Object [] messageInput = { prompt, jpf }; java.lang.Object [] options = { jpf , "OK", "Cancel"}; int result = JOptionPane.showOptionDialog(null, messageInput, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, ""); JOptionPane.showMessageDialog(null, result); if (result == 1) { password = jpf.getPassword(); } else if(result == JOptionPane.CANCEL_OPTION) { } return password; to get password, but this can not listen to the Enter button. I know if I set the options parameter to null, can make the dialog listen to "enter" button, but if I do that, the dialog don't focus to the textbox when show up. Can someone help me on this ? Thanks in advance !

    Read the article

  • Pass the current state of a function into another function in C/C++

    - by sand
    Is there a way to pass the current state of a function into another function in C/C++? I mean all the parameters and local variables by current state. For example: void funcA (int a, int b) { char c; int d, e; // Do something with the variables. // ... funcB(); // Do something more. } void funcB() { // funcB() should be able to access variables a,b,c,d & e // and any change in these variables reflect into funcA(). } The code is in bad shape if there is a need for funcB() kind of functions. But can it be achieved? This can help if someone is starting to re-factor a long method with multiple parameters.

    Read the article

  • How do I get the inner arrays length in a 2d array in C#?

    - by Phukab
    Lets say I create a jagged 2d array like so: public static char[,] phoneLetterMapping = { {'0'}, {'1'}, {'A', 'B', 'C'} }; Now, given the first index of the array, I would like to be able to get the length of the inner array. So, I would like to be able to do something like: phoneLetterMapping[2].length I can do that in Java. But the intellisense menu doesn't return the normal members of an array when I type in the first bracket of the [][] 2d array. So, how do I get the inner array lengths in my 2d array in C#?

    Read the article

  • C undefined reference to `some_foo'

    - by sterh
    Hello, I have 3 files in my gtk+ app: main.c: #include <gtk/gtk.h> #include <glib/gi18n.h> #include "mainwindow.h" int main(int argc, char** argv) { MainWin* win; GError* err = NULL; int a = 0; a = some_foo(); gtk_main(); return 0; } mainwindo.h #include <gtk/gtk.h> typedef struct _MainWin { GtkWindow parent; } MainWin; GtkWidget* main_win_new(); int some_foo(); MainWindow.c #include "mainwindow.h" int some_foo() { return 1; } When i try to call some_foo in main function, and try to compile i see error: undefined reference to `some_foo'. What's wrong? Thank you.

    Read the article

  • Appending item to lists - python

    - by ariel
    I have a list lets say a=[[1,2],[3,4],[5,6]]. I want to add to each item in a the char 'a'. when I use a=[x.append('a') for x in a] it return [None,None,None]. But if I use a1=[x.append('a') for x in a] then it do someting odd. a and not a1 is [[1,2,a],[3,4,a],[5,6,a]]. I don't understand why the first return [None, None, None] nor why the second works on a.

    Read the article

  • game currency convert: math efficient

    - by Comradsky
    For variables:4 text views named diamondText, goldText, silverText, and bronzeText;money variable unsigned int money;and an NSTimer, every .1 sec,runs function: -(void)updateMoney{ money++; bronzeText.text = [NSString stringWithFormat:@"%d",money]; silverText.text = [NSString stringWithFormat:@"%d",money%10]; goldText.text = [NSString stringWithFormat:@"%d",money%100]; diamondText.text= [NSString stringWithFormat:@"%d",money%1000]; } Given that my currency is diamond = 10 gold = 10 silver = 10 bronze = 1; What would be most efficient way to calculate and display the money labels? How would you store this variable, with GameCenter and NSDictionary or GameCenter and something else? More details are below if you don't understand. To clarify: bronze has the last 2 numbers, silver has the next 2 numbers, and so on. I understand I could use 4 ints or an array, but i would rather try to use this method, unless theres a much more efficient way. Example: When money = 1000;bronzeText = nothing, silverText = 10,goldText = nothing, diamondText = nothing; What other ways would you do this that you think would be more efficient? I will be calling a function (void)collisionDetector that detects if my player.frame crosses with a flyingObject.frame, and if that object is a coin it gives an added value to money and then calls (void)updateMoney. Im just using the timer to test this and spawn these flying objects.

    Read the article

  • printf'ing a matrix

    - by Flavius
    I'm trying to implement an all-purpose function for printing 2D data. What I've come up with is: int mprintf(FILE* f, char* fmt, void** data, size_t cols, size_t rows) The challenge is determining how many bits to read at once from data, based on fmt. The format fmt is going to be the stdlib's-specific format for printf() and alike. Do you have any knowledge of already-existing features from stdlibc (GNU GCC C's) I could use to ease this up? I try avoiding having to do it all manually, because I know "I am stupid" (I don't want to introduce stupid bugs). Thus, reusing code would be the bug-freest way. Thanks Addendum I see there's a /usr/include/printf.h. Can't I use any of those functions to do it right and ease my job at the same time?

    Read the article

  • Best way to get a date in .NET?

    - by frenchie
    I'm getting a string back from my page and I want to make sure it's a date. This is what I have so far (it works) and I just want to know if this is the "best" way to do it. I'm using .NET 4. int TheMonth =0; int TheDay = 0; int TheYear = 0; DateTime NewDate; var TheIncomingParam = Request.Params.Get("__EVENTARGUMENT").ToString(); char[] TheBreak = { '/' }; string[] TheOutput = TheIncomingParam.Split(TheBreak); try { TheMonth = Convert.ToInt32(TheOutput[0]); } catch { } try { TheDay = Convert.ToInt32(TheOutput[1]); } catch { } try { TheYear = Convert.ToInt32(TheOutput[2]); } catch { } if (TheMonth!=0 && TheDay!=0 && TheYear!=0) { try { NewDate = new DateTime(TheYear, TheMonth, TheDay); } catch { var NoDate = true; } }

    Read the article

  • Consolidating separate Loan, Purchase & Sales tables into one transaction table.

    - by Frank Computer
    INFORMIX-SE with ISQL 7.3: I have separate tables for Loan, Purchase & Sales transactions. Each tables rows are joined to their respective customer rows by: customer.id [serial] = loan.foreign_id [integer]; = purchase.foreign_id [integer]; = sale.foreign_id [integer]; I would like to consolidate the three tables into one table called "transaction", where a column "transaction.trx_type" [char(1)] {L=Loan, P=Purchase, S=Sale} identifies the transaction type. Is this a good idea or is it better to keep them in separate tables? Storage space is not a concern, I think it would be easier programming & user=wise to have all types of transactions under one table.

    Read the article

  • string holding text every \n

    - by gcc
    I tried to take input in form of string, specifically: int i=0; char c[50][500]; for(;i<50;++i) scanf("%s",A[i]); The input is x is a website that allows the easy[1] creation and editing of any number of interlinked web pages via a web browser using a simplified markup language or a WYSIWYG text editor. In my program, I want the text to be stored as: A[0]="x is a website that allows the easy[1] creation and editing of any number of interlinked" A[1]=" web pages via a web browser using a simplified markup language or a WYSIWYG text editor." But my code causes the text to be stored as A[0]="is" A[1]="a" A[2]="website" .... What am I doing wrong?

    Read the article

  • valid xml element in java replaceAll doesnt seem working well

    - by John
    Im trying to create a xml file from a POJO , in which i have a property that stores urls, I have been using the below method to replace all & in the url String to make the xml conform to standards and pass it as an html char entity but the string does not change. public static String forHrefAmpersand(String aURL){ return aURL.replaceAll("&", "&"); } the value might be www.abc.com/controller?a=1&next=showResults I have even tried changing the above method to use "/" as i read replaceAll uses regular expression but replaceAll is not working as exprected, Can anyone tell me what is the mistake im doing ? Thanks in advance

    Read the article

  • Preserve trailing whitespace Sybase

    - by AngryWhenHungry
    I have a big chunk of textual data which I split and write multiple rows of a varchar(255) column of a table. Sometimes, the last character happens to be a space. When I read back this row, the trailing space is chopped and I get only 254 characters. This messes up my data when I append the next row to the end of this one. My code sends the full 255 char (incl space) to the DB API. How can I check that the trailing space is actually written to the table? I am not in a position to rewrite/redesign legacy code. Is there any setting - either in the DB, DB interface, read/write calls etc - that I can use to preserve the trailing space?

    Read the article

  • can we write this in C++ switch ?

    - by jellly
    #include <iostream> using namespace std; int main(){ char i; cin >>i; switch (i){ case ('e'||'i'||'o'||'u'||'a'): cout<<"Vowel"; break; case ('+'||'-'||'/'||'*'||'%'): cout<<"Op"; break; } return 0; } if not than how can we use comparison or logical operators in switch ? & why cant we declare and initialize variable in single case without using scope ?

    Read the article

  • How to check whether iterators form a contiguous memory zone?

    - by Vincent
    I currently have the following function to read an array or a vector of raw data (_readStream is a std::ifstream) : template<typename IteratorType> inline bool MyClass::readRawData( const IteratorType& first, const IteratorType& last, typename std::iterator_traits<IteratorType>::iterator_category* = nullptr ) { _readStream.read(reinterpret_cast<char*>(&*first), (last-first)*sizeof(*first)); return _readStream.good(); } First question : does this function seem ok for you ? As we read directly a block of memory, it will only work if the memory block from first to last is contiguous in memory. How to check that ?

    Read the article

  • Why isn't the compiler smarter in this const function overloading problem?

    - by Frank
    The following code does not compile: #include <iostream> class Foo { std::string s; public: const std::string& GetString() const { return s; } std::string* GetString() { return &s; } }; int main(int argc, char** argv){ Foo foo; const std::string& s = foo.GetString(); // error return 0; } I get the following error: const1.cc:11: error: invalid initialization of reference of type 'const std::string&' from expression of type 'std::string* It does make some sense because foo is not of type const Foo, but just Foo, so the compiler wants to use the non-const function. But still, why can't it recognize that I want to call the const GetString function, by looking at the (type of) variable I assign it to? I found this kind of surprising.

    Read the article

  • MVC 3 Razor PopUp Window

    - by Vipul
    I need to open a new pop up window on click of a button in a view. The new window should be redirect to a specific actionmethod in a specific controller. I also need to provide attributes for size of the new pop up window. I have been trying the following code: <input type="button" name = "ClickMe" Value="ClickMe" onclick= "javascript:window.open('/Home/Create/','Customer Search',height='window.screen.height - 100', width='200',left='window.screen.width - 250' ,top='10',status='no',toobar='no',resizable='yes',scrollbars='yes')"/> On click of button, nothing happens. I get following Javascript error: Line: 19 Char: 1 Error: Invalid argument. Code: 0 When I check the ViewSource of the HTML rendered, I find the line to be the one which is rendering the button. I am using Windows Vista with IE 7. I am working on MVC 3 with Razor Engine in VS 2010

    Read the article

  • Can't subtract in a for loop in C/Objective-C

    - by user1612935
    I'm going through the Big Nerd Ranch book on Objective-C, which takes you through some early C stuff. I've played with C before, and am pretty experienced in PHP. Anyhow, I'm doing the challenges and this one is not working the way I think it should. It's pretty simple - start at 99, loop through and subtract three until you get to zero, and every time you get a number that is divisible by 5 print "Found one." Pretty straightforward. However, subtracting by three in the for loop is not working #include <stdio.h> int main (int argc, const char * argv[]) { int i; for(i = 99; i > 0; i-3){ printf("%d\n", i); if(i % 5 == 0) { printf("Found one!\n"); } } return 0; } It creates and endless loop at 99, and I'm not sure why.

    Read the article

  • Print unique ascii characters in eclipse console

    - by Shaded
    Hey guys, Kind of a strange question but... here it goes. Recently my application threw an IOException that the text only had a clubs symbol in it (like the suit in cards) I know this is probably because there was a number in there that was cast to a char and printed to the screen, and I've found where that might have happened. The only problem is, I can't recreate it in eclipse because the eclipse console doesn't want to print those characters for me. All I get are boxes. I figure this is an encoding issue or something but I need eclipse to print out those characters just like the windows console would. Is there a setting I can change to do this?

    Read the article

  • Changing file permissions in kernel.

    - by Mehrdad
    I am writing kernel module(C in Linux) and I want to change the permission of the other files in it. any solution? since I am in kernel I can't use chmod syscall and ... thanks for your help This is my Makefile: > obj-m += ca.o > > all: > make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules > > clean: > make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean And this is my Code: > #include <linux/string.h> > #include <linux/mm.h> > /* Snip, tons of includes (all of them :))*/ > #include <linux/delay.h> .... int procfile_write(struct file *file, > const char *buffer, unsigned long > count, > void *data) { ... sys_chmod(path, per); ... } ... When Making it gives a warning: WARNING: "sys_chmod" [file] undefiened and when loading the module with "sudo insmod" it gives this error: Unknown sybol in module it seems that this error happens especialy in kernel modules. any idea? again thanks!

    Read the article

  • Programmatically check whether a linux kernel module exists or not at runtime

    - by dgraziotin
    I am writing a C daemon, which depends on the existence of two kernel modules in order to do its job. The program does not directly use these (or any other) modules. It only needs them to exist. Therefore, I would like to programmatically check whether these modules are already loaded or not, in order to warn the user at runtime. Before I start to do things like parsing /proc/modules or lsmod output, does a utility function already exist somewhere? Something like is_module_loaded(const char* name); I am pretty sure this has been asked before. However, I think I am missing the correct terms to search for this. Thanks!

    Read the article

  • Unit testing a functions whose purposes is side effects

    - by David
    How would you unit test do_int_to_string_conversion? #include <string> #include <iostream> void do_int_to_string_conversion(int i, std::string& s) { switch(i) { case 1: s="1"; break; case 2: s="2"; break; default: s ="Nix"; } std::cout << s << "\n"; } int main(int argc, char** argv){ std::string little_s; do_int_to_string_conversion(1, little_s); do_int_to_string_conversion(2, little_s); do_int_to_string_conversion(3, little_s); }

    Read the article

< Previous Page | 187 188 189 190 191 192 193 194 195 196 197 198  | Next Page >