C :: Warning - Unknown Escape Sequence

Feb 2, 2013

I'm doing some file input/output work here in C and received this warning during compilation (GCC). My research indicates that this error is in response to white space or a character cancellation function or something like that. I'm not 100% sure exactly what it means. My code works fine, but the following warning does appear.

Code:
warning: unknown escape sequence: '40'

Here's my code (excluding a bunch of comments at the bottom of the file).

Code:
#include <stdio.h>
int main(void){
FILE *file;
file = fopen("Running Practice.c", "a");
fprintf(file, "Testing...
");
fclose(file);
}

I believe the error I received has to do with either the ' ' I used when appending text to my file, or something to do with there being a space in the file name itself.

View 6 Replies


ADVERTISEMENT

C :: Save Output From Ansi Escape Sequence To Variable

Apr 13, 2013

I'm trying to get the current position of the cursor in the terminal window. I know that the ansi escape sequence "33[6n" will display the current x and y location of the cursor. But what I can't figure out is how to store the x and y locations into their respective integer variables.

This is what I've done so far:

Code:
#include <stdio.h>
int main(void) {
int line, column;
char cursor_curr_pos[9];
char escape_sequence[] = "33[6n"; //outputs x and y location of cursor e.g. ^[[18;1R
snprintf(cursor_curr_pos, 9, "%s", escape_sequence); //save output to string
sscanf(cursor_curr_pos, "^[[%d;%dR", &line, &column); //only read numbers from string
}

View 2 Replies View Related

C Sharp :: Write Escape Sequence For Epson Printer

Sep 7, 2012

I want to send control codes for Epson printer with c# application, I wrote some code, I have the connection with the printer, but when I am sending codes it not responding. On the other side, I found Java application for sending control codes, from that app some of the codes is working but not all of them. For example I want to use ESC EM 66 control code but when I am sending this code, printer not responding or just print the code in numbers.

The code who I use is:

class Program {
public const short FILE_ATTRIBUTE_NORMAL = 0x80;
public const short INVALID_HANDLE_VALUE = -1;

[Code]....

When I am using the method GetDocument() printer is not responding, but it prints only text when I call the buffer variable:

lpt.Write(buffer, 0, buffer.Length);

View 1 Replies View Related

C++ :: Passing Unknown Arguments To Unknown Function

May 1, 2013

So I'm making setTimeout and setInterval functions.

I have this remember function (that is part of Timing class) which takes a function pointer and a void pointer, which are remembered in that object.

Another (timing) function of that object is called in every loop of the program and when specific time passes that function calls the remembered function whit the remembered void pointer as argument.

The problem is that the functions that need to be called require unknown multiple parameters, so what I need to do is make a new class that will store the needed arguments. I make the function that needs to be called and that storage object and pass pointers to them to my remember function, when the remembered function is called it stores the data from storage object in new variables and dose it's thing.

View 3 Replies View Related

C :: Print String With Escape Characters

Mar 7, 2013

is there any function to print a string with all the escape characters in it?

For example, instead of printing:
This is a string.

It would print:
This is a string.

Or in Windows:
This is a string.

I know that you can debug the code to find the variable contents, but is there any way to accomplish this with some standard library function?

View 6 Replies View Related

C/C++ :: Splint Warning In GCC Compiler?

Jun 7, 2012

/*@out@*//*@null@*/char *string_read ( ) {
int ch , pos = 0;
char *string;
if ((string = (char *)malloc (STRING_SIZE*sizeof(char))) == NULL)

[Code] ......

Fresh storage string not released before return A memory leak has been detected. Storage allocated locally is not released before the last reference to it is lost. (Use -mustfreefresh to inhibit warning) string_read.c:6:7: Fresh storage string created

View 1 Replies View Related

C :: Warning When Handling Pointer To Char

Apr 4, 2014

Here is my code. I am combining two words and sorting the merge word in alphbetical order. The compiler giving me warning error

Program:12:4: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat] Program:14:4: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat]

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

[Code].....

View 3 Replies View Related

C :: Compiling Warning - Output Is Garbage

Mar 23, 2013

I'm working on my program that takes input of the employees' first and last name, their payrate, their deferred from check and also the amount of hours they have worked which then the gross is calculated and also the taxes are calculated by an external function. In the program design it is necessary to put arrays which I have done, but when i compile I receive warning messages

Code: warning: format '%s' expects argument of type 'char*', but argument 3 has type 'double'

Warning: format '%f' expects a matching 'double' argument [-Wformat] which I believe is causing my program to just give me garbage when I run it. What do those warnings mean?

Code:
/* Name: Arturo
Date: 03/22/13
Purpose: To learn
*/
extern void calculate taxes(float gross,float deferred, float *ft, float *st, float ........i);
void ovtHrs(float *hrs_wrk, float *ovt_hrs, float hrs, float *gross, float payrate);
void netPay(float gross, float deferred, float ft, float st, float ssi, float *net);

[Code] .....

View 9 Replies View Related

C++ :: Temp Or Local Variable Warning

Feb 28, 2014

Here is my overloaded operator :

const double & Waz::operator()(int i,int j) const {
return ((WazImpl const)(*p))(i,j);
}

Where in Waz class I have : WazImpl* p; and in the class WazImpl I have an operator () const

The warning is : Warning C4172 returning address of local variable or temporary

As far as I understand I'm returning a temp variable which is destroyed somewhere else what can I do to fix it?

View 2 Replies View Related

C/C++ :: Difference Between Compiler Error And Warning?

Jun 8, 2013

in c program what is the difference between a compiler error and a warning

View 1 Replies View Related

C :: How To Remove Multi Character Constant Warning

Feb 20, 2013

Here's the line of code with the warning

Code: if((addressbook[3][num][4]=='-')&&(strlen(addressbook[3][num])=='10'))

Or what might be the possible causes of such a warning?

View 2 Replies View Related

C/C++ :: Warning - Cast From Pointer To Integer Of Different Size

Jan 23, 2014

int hash = 0;
char *strings[100];
if((int)strings[i] != 0)
if((int) strings[hash] != 0)
while((int) strings[hash] != 0)
if((int)strings[hash] != 0)
if((int)strings[hash] != 0)

View 12 Replies View Related

C++ :: Fraction Class - Warning Converting To Int From Double

Jul 28, 2013

I am trying to write a Fraction class and getting the following warning when compiling my code :

Fraction.cpp: In constructor 'Fraction::Fraction(double)':
Fraction.cpp:8: warning :converting to 'int' from 'double'

My Fraction.cpp class looks like :

#include "Fraction.h"
Fraction::Fraction(int n, int d):num(n),den(d) {
cout << This is double param constructor <<endl;
}
Fraction::Fraction(double d):num(d),den(0)

[Code] ....

How can I get rid of the warning ?

View 8 Replies View Related

C/C++ :: Warning / Assignment From Incompatible Pointer Type

Apr 17, 2014

I'm working on a program and everything works except for the follow function:

void swapHex(int x, int byte1, int byte2) {
unsigned char *b1, *b2, tmpc;
printf("%d in hex is %x
", x, x);
printf("swapping byte %d with byte %d
", byte1, byte2);

[Code] ....

I get the following errors when compiling:

In function "swapHex":
warning: assignment from incompatible pointer type
warning: assignment from incompatible pointer type

View 2 Replies View Related

C/C++ :: Warning / Control Reaches End Of Non-void Function

Apr 25, 2013

I keep getting 'warning: control reaches end of non-void function' with this code:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {  
 if (section ==0)  {
  return [comparativeList count];
 }  
 if (section==1)  {
  return [generalList count];
 }  
 if (section==2) {  
  return [contactList count];

How can I get rid of this warning?

View 3 Replies View Related

C :: Implementing Recursive Merge Sort - Forbid Warning

Jul 8, 2013

I am trying to implement a recursive merge sort, and I've just barely begun. I am getting some warnings:

merge_sort.c:15: warning: ISO C90 forbids variable-size array 'left'
merge_sort.c:15: warning: ISO C90 forbids mixed declarations and code

Code:
#include <stdio.h>
#include <string.h>

static void
merge_sort(int *a, int n)

[Code] ....

I am using gcc 4.2.1 and I am compiling with -Wall and -pedantic.

View 6 Replies View Related

C :: Create Multiple Choice Quiz Works But With A Warning

Apr 10, 2013

I am trying to create a multiple choice quiz so I can learn the menu at my new job, while doing a side project but I am having a warning when outputting. Speaking of side projects, is this a kind of side project people are looking for on a resume?

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
}

[code]....

View 8 Replies View Related

C :: Warning - Return Makes Pointer From Integer Without A Cast

Sep 21, 2013

I have a function that I want to exit gracefully when an "error" occurs in an input file. My function declaration is:

Code: BSTnode *buildTree(FILE *fp)

The few lines that are causing the problems are:

Code: if(regcomp(®ex, to_find, REG_EXTENDED | REG_NEWLINE) != 0) {
fprintf(stderr, "Failed to compile regex '%s'
", to_find);
return EXIT_FAILURE;
}

I know that if I just use "return" by itself the warning goes away but fails to exit when the error occurs. I also believe this may not be the correct use of stderr. But I need the program to exit when an error has occurred.

View 9 Replies View Related

C++ :: Add Some Warning Message When Imputing Date Is Older Than Preset Value

Sep 5, 2014

recently I wanted to add some warning message when imputing date (DD.MM.YY) is older than some pre-set value.

day DD
month MM
year YY

pre-set date 21.7.2014

The condition I have is

if((YY < 2014) ||
(YY == 2014 && MM < 7) ||
(YY == 2014 && MM == 7 && DD < 21){
//warning message
}

Now I was just curious if there is easier way to implement this condition. To use less code. When I extend the condition to hour:minute:second the code would only grow fast. Also I know I should not use "magic numbers" but it is only for the demonstration.

View 3 Replies View Related

C :: Syntax Error At The End Of Input And Warning (multi-character Constant)

Feb 18, 2013

Here's my code. The error's at the last line.

Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define max_con 30

void add_contact();
void edit_contact();
void del_contact();
void list_contact();

[Code] .....

View 6 Replies View Related

C++ :: Matrix With Unknown Dimension?

Feb 18, 2014

I try to write code for one problem which is worked with the matrix.I have written in specific size 5 by 5 and I know the general formula for these matrix based on dimension,I want to write a general form that take the matrix size and then create my favor matrix.However,when I write like below the following error is appeared

int m;
cin>>m;
int A[m][m];

Error: m must be constant

View 2 Replies View Related

C/C++ :: Unknown Type Name PGconn

Feb 27, 2015

I have the following code

#include <stdio.h>
#include <stdlib.h>
#include <postgresql/libpq-fe.h>

[Code].....

View 2 Replies View Related

C++ :: Cin And Unknown Number Of Integers

Dec 2, 2012

i dont usually write console programs, and i cant seem to find out how one parses an unknown number of arguments with cin.

the program receives an unknown amount of integers in stdin, and i need to parse them withouth hanging.

Unfortunately, stdin is a async. stream and blocks, if it doesnt find any integers left.

I cant use peek() or seek() either, as both are async, too, (which makes me wonder what their exact use is?).

View 3 Replies View Related

C :: Passing Argument Of Incompatible Pointer Type - Warning In Function Call In Main

Jun 4, 2013

Code:
#include <stdio.h>
#include <stdlib.h>
int size_b_row1;
int size_b_col1;

[Code].....

View 2 Replies View Related

C :: Reading Files Of Unknown Size

Jan 23, 2013

I want my program to be able to read text files in the format:

number number
number number
number number...

and so on, so there are two columns of values. The problem I'm having is, there are a lot of numbers in the file, and it can vary. The program needs to read the numbers, put one column into one array, and the other in another, perform some operations on it all, and eventually pop out two different arrays. In other words, after I've got these arrays, I don't need them for much longer. I was hoping I could dynamically allocated some arrays to store the numbers and just free them as soon as I'm done with them.

If the file wasn't of such variable size or if it was guaranteed to be under a certain number of variables, I would have used:

Code:

while ( fscanf(input, "%lf %lf
", &col_1[], &col_2[]) == 2 )
{
no_rows++;
}

The problem is I want to allocate "no_rows" as the array size, which I don't have until after I have read the file.

View 9 Replies View Related

C :: How To Save Returned Of Unknown Length

Sep 15, 2014

I call a function that returns a string, and I can print it out fine, but I want to test the result of the function to see if it returns 0. But I can't just call the function again (GetNextToken(b)) because it will generate a different token. I can't allocate space for the string because I'm not sure what the size of the returned string is going to be.

Basically I want to see if the GetNextToken(b) returns 0, and if it doesn't then print the string. And running GetNextToken(b) again will give a different result.

Code:
int main(int argc, char **argv) {
SomeStruct* b = CreateStruct(argv[1],argv[2]);
printf("HERE %s", GetNextToken(b));

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved