Erro na função write do stringstream do c++


estou fazendo uma função para conversão de decimal para binário, que é retornado numa string. Como o C++ não tem StringBuffer, estou usando o stringstream. Contudo, sempre tenho erro de compilação ao usar a função write do stringstream. O código é este:

string toBin(int valor, int bits) {     int resto = -1, i = 0;     stringstream ss;      if (valor == 0) {         return "0";     }      while (valor > 0) {         resto = valor % 2;         valor = valor / 2;         ss.seekp(0);         ss.write(resto, i++);     }      return ss.str(); } 

A intenção é que a cada resto encontrado, eu o insira na primeira posição do stringstream, para formar o binário. E o erro encontrado é:

“invalid conversion from ‘int’ to ‘const char*’

Como poderia resolver esse problema? Ou existe alguma biblioteca do C++ que já faça a conversão de decimal para binário?


Can’t Block Russian Spammers Because Can’t Write In Russin

I get these messages, or notifications from some Russians, or at least I think they are, maybe Ukrainians, asking me to like pages, all of them with beautiful sexy women. I can't block them because I can't write their name in Russian.

what can I do about this?? I get quite a few every day.

darn trying to attach a screenshot but it says photo too large, but I've resized it to 158KB or 500 pixels wide?

atprogram.exe – no boot after write command

I am using the atprogram.exe to flash an several atmega256rfr2 via batchfile and AtmelIce programmer on a windows machine.

I wrote some code that just does a simple printf("Hello World\n"); after initialising the designated UART.

Now when I am flashing one atmega with a batchfile (sequence: erase chip, set fuse without eesave, erase chip incl. eeprom, write flash with verification)


set debugger= atmelice  ::erase echo ####### erase chip ####### atprogram -t %debugger% -i jtag -d atmega256rfr2 -cl 2mhz -xr chiperase || EXIT /B 1  ::fuses without eesave echo ####### set fuse without eesave ####### atprogram -t %debugger% -i jtag -d atmega256rfr2 -cl 2mhz -xr write -fs -v --values CE9AFF || EXIT /B 1  ::erase echo ####### erase chip including eeprom ####### atprogram -t %debugger% -i jtag -d atmega256rfr2 -cl 7mhz -xr chiperase || EXIT /B 1  ::program echo ####### write flash ####### atprogram -t %debugger% -i jtag -d atmega256rfr2 -cl 7mhz -xr program --verify -f mylil.hex || EXIT /B 1 

Now when I program my develop-atmega with this script, everything is running well, “Hello World” is printed on the UART after the process is finished.

BUT if I try to flash an untouched (factory default) the script is running as it should, but after the script finishes nothing is printed in the UART.

I also tried to add the following part at the end of the script

::reset echo ####### reset device ####### atprogram -t %debugger% -i jtag -d atmega256rfr2 -cl 7mhz reset || EXIT /B 1 

but this also didn’t help. If i flash an untouched atmega via ATMEL studio 7.0 everything is working fine and the µC starts as normal, prints “Hello World”.

Am I doing something wrong in the Script? Do I need to touch the user signature of the board?

Thx in advance

Accurately Write 1000 Words Unique Article for $5

I will compose Unique Articles PREMIUM Quality in any specialty as you need…. 100% Unique, SEO Friendly and CopyScape Pass! This article is 100% remarkable literary theft checker and Great Quality. I am composing this article with the consequences of research from sources on the Internet, at that point make a rundown and subsequently be 100% one of a kind article. You will get premium articles of 1000 word+ Get novel articles for your blog entries; Money Site, AdSense blog, PBN or any of your concern. Premium quality articles that are SEO benevolent, great quality (meaningful well), 100% one of a kind and CopyScape go to enhance the SEO positioning your blog or site in a web crawler (Google, Bing, Yahoo, and the sky is the limit from there). I will compose the exceptional article in any specialty, understanding with your blog specialty. A normal 400 words for each article, can be less or much more. ☀ Note: This article is elite, which won’t show up anyplace else at any site!

by: AccurateWriter
Created: —
Category: Article Writing
Viewed: 228

Accurately Write 1200 Word Unique Content for $5

UNIQUE CONTENT PROVIDED HERE SEO and Articles play a great and vital role in website ranking. Without quality and friendly SEO articles, you cannot get high ranking in search engine. If you are bother from bad content. Then, you are at right place. I will write 3 articles of 400 words for only $ 5. So why are you afraid just order this gig and get amazing article writing service.

by: AccurateWriter
Created: —
Category: Content & Writing
Viewed: 210

Write a Guest post on DA76 Dofollow backlink for $25

SEO Guest posting is renowned as an ethical and beneficial way to increase not only your positions in the SERPs but also the natural traffic to your site from the post placement itself and also social media means. I will publish your article on (DA – 76) for just 30$ Site Metrics: Domain Authority (DA): 76 Page Authority (PA) : 61 Google Page Rank (PR): 6 DO-FOLLOW Back Link So, you’re probably wondering what you get with this Hourlie – here’s what you receive with our link building service:• A 450 + Word piece • SEO optimized • Includes images • You can supply the topic if you want – otherwise I’m more than happy to choose. • Truly white hat Panda and Penguin friendly guest posting

by: Nunku
Created: —
Category: Guest Posts
Viewed: 95

Is there a cleaner way to write this program?

as a beginner’s assignment i had to write a program that recieves 2 Strings, Input and Search, in the Search string the sign ‘+’ indicates that it should tell me if the substring before the ‘+’ exists in the Input string. (the search String cannot start with ‘+’ and there cannot be a ‘+’ followed by another ‘+’).

I was wondering, if it is possible, because I am a beginner, for someone to help me or give me tips on how to write cleaner code. I do think that I write unnecessary lines and hoped to get better at this.

boolean notgood = false;                     boolean break1 = false;                     boolean break2 = false;                     int counter = 0;                      if (search.charAt(0)=='+'||search.charAt(0)=='*') {                          System.out.println("Invalid search striNG.");                         continue;                      }                      //////////////////////////////////////////////                     for (i=0; i<search.length() && notgood==false; i++) {                          if (search.charAt(i)!='*' && search.charAt(i)!='+') {                             counter++;                         }                         if (counter == search.length()) {                             System.out.println("Invalid SEARCH string.");                              notgood=true;                             break;                         }                          if ((search.charAt(i)=='*')||(search.charAt(i)=='+')) {                              if (i!=search.length()-1) {                                   if ((search.charAt(i+1)=='*')||(search.charAt(i+1)=='+')) {                                      System.out.println("INvalid search string.");                                      notgood=true;                                     break1=true;                                 }                             }                          }                     }                     ////////////////////////////////////////////                     for (i=0; i<search.length() && !break1; i++) {                           int c=0;                          if (search.charAt(i)=='+') {                                    String word = search.substring(0,i);                               for (int j=0; j<input.length() && !break2; j++) {                                   if ((input.charAt(j) == word.charAt(c)) && c<word.length()) {                                      c++;                                 }                                 if (c>=word.length()) {                                      System.out.println("Search string matches input string.");                                     break1=true;                                     break2=true;                                  }                             }                              if (c<word.length()) {                                 System.out.println("Search string doesn't match input string.");                             }                         } 

For example, Input = ‘abcd’ and search = ‘ab+cd+’, the result should be ‘the strings match.

Do 10X High-Authority Guest Post Write & Publish DA50+ for $125

***Do you want high quality, relevant backlinks from authority sites that shoot up your Google ranking and leave your competitors looking like distressed typists?*** Then this service is for you— I will write 10 top-notch articles and publish them on 10 popular blogs with at least Domain Authority (DA) 50 to post them. Each article will be original, well written and highly shareable. Each article will be relevant to your niche and contain a dofollow link to your website with your desired anchor text. Here are some more details about this service: Link type: Dofollow Blog authority: DA50+ Private Blog Network (PBN)? : No! These are real blogs. Please note: I cannot accept sites in the following niches: gambling, dating, adult and pharmacy. If you have any question, feel free to ask me.

by: Nunku
Created: —
Category: Guest Posts
Viewed: 137